@contrast/agent-bundle 5.45.1 → 5.47.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 (189) hide show
  1. package/README.md +1 -1
  2. package/node_modules/@contrast/agent/README.md +1 -1
  3. package/node_modules/@contrast/agent/package.json +12 -12
  4. package/node_modules/@contrast/agentify/package.json +15 -15
  5. package/node_modules/@contrast/architecture-components/package.json +5 -5
  6. package/node_modules/@contrast/assess/lib/{session-configuration → configuration-analysis}/common.js +1 -1
  7. package/node_modules/@contrast/assess/lib/{session-configuration → configuration-analysis}/handlers.js +24 -11
  8. package/node_modules/@contrast/assess/lib/{session-configuration → configuration-analysis}/index.js +6 -4
  9. package/node_modules/@contrast/assess/lib/configuration-analysis/install/apollo-server.js +92 -0
  10. package/node_modules/@contrast/assess/lib/{session-configuration → configuration-analysis}/install/express-session.js +2 -2
  11. package/node_modules/@contrast/assess/lib/{session-configuration → configuration-analysis}/install/fastify-cookie.js +2 -2
  12. package/node_modules/@contrast/assess/lib/configuration-analysis/install/graphql-yoga.js +90 -0
  13. package/node_modules/@contrast/assess/lib/{session-configuration → configuration-analysis}/install/hapi.js +2 -2
  14. package/node_modules/@contrast/assess/lib/{session-configuration → configuration-analysis}/install/koa.js +3 -3
  15. package/node_modules/@contrast/assess/lib/dataflow/propagation/install/string/substring.js +1 -1
  16. package/node_modules/@contrast/assess/lib/dataflow/sources/handler.js +30 -26
  17. package/node_modules/@contrast/assess/lib/dataflow/sources/index.js +2 -0
  18. package/node_modules/@contrast/assess/lib/dataflow/sources/install/fastify-websocket.js +63 -0
  19. package/node_modules/@contrast/assess/lib/dataflow/sources/install/http.js +42 -38
  20. package/node_modules/@contrast/assess/lib/dataflow/sources/install/koa/index.js +1 -1
  21. package/node_modules/@contrast/assess/lib/dataflow/sources/install/koa/koa-bodyparsers.js +76 -48
  22. package/node_modules/@contrast/assess/lib/dataflow/sources/install/koa/koa-multer.js +1 -1
  23. package/node_modules/@contrast/assess/lib/dataflow/sources/install/koa/koa-routers.js +2 -2
  24. package/node_modules/@contrast/assess/lib/dataflow/sources/install/koa/{koa2.js → koa.js} +3 -3
  25. package/node_modules/@contrast/assess/lib/dataflow/sources/install/socket.io.js +80 -0
  26. package/node_modules/@contrast/assess/lib/get-source-context.js +10 -21
  27. package/node_modules/@contrast/assess/lib/index.d.ts +4 -3
  28. package/node_modules/@contrast/assess/lib/index.js +2 -2
  29. package/node_modules/@contrast/assess/lib/make-source-context.js +5 -10
  30. package/node_modules/@contrast/assess/lib/policy.js +400 -0
  31. package/node_modules/@contrast/assess/lib/response-scanning/handlers/index.js +10 -14
  32. package/node_modules/@contrast/assess/package.json +12 -12
  33. package/node_modules/@contrast/common/lib/constants.d.ts +12 -4
  34. package/node_modules/@contrast/common/lib/constants.js +16 -7
  35. package/node_modules/@contrast/common/lib/types.d.ts +5 -1
  36. package/node_modules/@contrast/common/package.json +1 -1
  37. package/node_modules/@contrast/config/lib/common.js +1 -0
  38. package/node_modules/@contrast/config/lib/options.js +14 -0
  39. package/node_modules/@contrast/config/package.json +3 -3
  40. package/node_modules/@contrast/core/package.json +5 -5
  41. package/node_modules/@contrast/deadzones/package.json +5 -5
  42. package/node_modules/@contrast/dep-hooks/lib/package-finder.d.ts +2 -2
  43. package/node_modules/@contrast/dep-hooks/lib/package-finder.js +3 -2
  44. package/node_modules/@contrast/dep-hooks/package.json +4 -4
  45. package/node_modules/@contrast/esm-hooks/README.md +2 -2
  46. package/node_modules/@contrast/esm-hooks/package.json +6 -6
  47. package/node_modules/@contrast/instrumentation/package.json +5 -5
  48. package/node_modules/@contrast/library-analysis/lib/install/library-reporting/dep.json +149 -149
  49. package/node_modules/@contrast/library-analysis/lib/install/library-reporting/index.js +2 -11
  50. package/node_modules/@contrast/library-analysis/lib/install/library-reporting/utils.js +2 -0
  51. package/node_modules/@contrast/library-analysis/lib/install/library-usage/index.js +3 -1
  52. package/node_modules/@contrast/library-analysis/lib/util.js +0 -2
  53. package/node_modules/@contrast/library-analysis/package.json +4 -4
  54. package/node_modules/@contrast/logger/package.json +3 -3
  55. package/node_modules/@contrast/metrics/package.json +6 -6
  56. package/node_modules/@contrast/patcher/package.json +2 -2
  57. package/node_modules/@contrast/protect/lib/error-handlers/index.js +1 -1
  58. package/node_modules/@contrast/protect/lib/error-handlers/install/{koa2.js → koa.js} +4 -4
  59. package/node_modules/@contrast/protect/lib/index.d.ts +1 -1
  60. package/node_modules/@contrast/protect/lib/input-analysis/handlers.js +1 -12
  61. package/node_modules/@contrast/protect/lib/input-analysis/index.js +2 -3
  62. package/node_modules/@contrast/protect/lib/input-analysis/install/koa-bodyparsers.js +92 -0
  63. package/node_modules/@contrast/protect/lib/input-analysis/install/{koa2.js → koa.js} +5 -5
  64. package/node_modules/@contrast/protect/package.json +11 -11
  65. package/node_modules/@contrast/reporter/lib/reporters/contrast-ui/endpoints/application-activity/translations.js +6 -10
  66. package/node_modules/@contrast/reporter/lib/reporters/contrast-ui/endpoints/routes-observed.js +4 -0
  67. package/node_modules/@contrast/reporter/lib/reporters/contrast-ui/endpoints/traces/index.d.ts +1 -1
  68. package/node_modules/@contrast/reporter/lib/reporters/contrast-ui/endpoints/traces/index.js +1 -1
  69. package/node_modules/@contrast/reporter/lib/reporters/contrast-ui/endpoints/traces/translations.d.ts +1 -1
  70. package/node_modules/@contrast/reporter/lib/reporters/contrast-ui/endpoints/traces/translations.js +22 -9
  71. package/node_modules/@contrast/reporter/lib/reporters/file.js +1 -1
  72. package/node_modules/@contrast/reporter/package.json +6 -6
  73. package/node_modules/@contrast/rewriter/package.json +5 -5
  74. package/node_modules/@contrast/route-coverage/lib/index.d.ts +0 -2
  75. package/node_modules/@contrast/route-coverage/lib/index.js +10 -1
  76. package/node_modules/@contrast/route-coverage/lib/install/express/express5.js +16 -1
  77. package/node_modules/@contrast/route-coverage/lib/install/fastify.js +25 -15
  78. package/node_modules/@contrast/route-coverage/lib/install/graphql.js +6 -1
  79. package/node_modules/@contrast/route-coverage/lib/install/koa.js +1 -1
  80. package/node_modules/@contrast/route-coverage/lib/install/socket.io.js +127 -0
  81. package/node_modules/@contrast/route-coverage/package.json +8 -8
  82. package/node_modules/@contrast/scopes/package.json +5 -5
  83. package/node_modules/@contrast/sec-obs/package.json +9 -9
  84. package/node_modules/@contrast/sources/lib/index.js +65 -22
  85. package/node_modules/@contrast/sources/lib/index.test.js +78 -33
  86. package/node_modules/@contrast/sources/lib/source-info.js +1 -10
  87. package/node_modules/@contrast/sources/package.json +3 -3
  88. package/node_modules/@contrast/telemetry/package.json +5 -5
  89. package/node_modules/@types/node/README.md +1 -1
  90. package/node_modules/@types/node/assert/strict.d.ts +105 -2
  91. package/node_modules/@types/node/assert.d.ts +154 -95
  92. package/node_modules/@types/node/buffer.buffer.d.ts +9 -0
  93. package/node_modules/@types/node/buffer.d.ts +8 -4
  94. package/node_modules/@types/node/child_process.d.ts +65 -42
  95. package/node_modules/@types/node/cluster.d.ts +4 -5
  96. package/node_modules/@types/node/crypto.d.ts +1173 -322
  97. package/node_modules/@types/node/dgram.d.ts +9 -8
  98. package/node_modules/@types/node/diagnostics_channel.d.ts +0 -2
  99. package/node_modules/@types/node/dns.d.ts +1 -1
  100. package/node_modules/@types/node/events.d.ts +80 -34
  101. package/node_modules/@types/node/fs/promises.d.ts +39 -21
  102. package/node_modules/@types/node/fs.d.ts +328 -87
  103. package/node_modules/@types/node/globals.d.ts +2 -0
  104. package/node_modules/@types/node/globals.typedarray.d.ts +19 -0
  105. package/node_modules/@types/node/http.d.ts +94 -30
  106. package/node_modules/@types/node/http2.d.ts +178 -52
  107. package/node_modules/@types/node/https.d.ts +91 -62
  108. package/node_modules/@types/node/index.d.ts +2 -0
  109. package/node_modules/@types/node/inspector.d.ts +24 -0
  110. package/node_modules/@types/node/inspector.generated.d.ts +181 -0
  111. package/node_modules/@types/node/net.d.ts +12 -11
  112. package/node_modules/@types/node/os.d.ts +14 -3
  113. package/node_modules/@types/node/package.json +3 -3
  114. package/node_modules/@types/node/perf_hooks.d.ts +6 -8
  115. package/node_modules/@types/node/process.d.ts +12 -23
  116. package/node_modules/@types/node/readline/promises.d.ts +1 -1
  117. package/node_modules/@types/node/sea.d.ts +9 -0
  118. package/node_modules/@types/node/sqlite.d.ts +119 -10
  119. package/node_modules/@types/node/stream/consumers.d.ts +2 -2
  120. package/node_modules/@types/node/stream/web.d.ts +6 -55
  121. package/node_modules/@types/node/stream.d.ts +38 -23
  122. package/node_modules/@types/node/string_decoder.d.ts +2 -2
  123. package/node_modules/@types/node/test.d.ts +31 -26
  124. package/node_modules/@types/node/tls.d.ts +90 -66
  125. package/node_modules/@types/node/ts5.6/buffer.buffer.d.ts +10 -2
  126. package/node_modules/@types/node/ts5.6/globals.typedarray.d.ts +16 -0
  127. package/node_modules/@types/node/ts5.6/index.d.ts +2 -0
  128. package/node_modules/@types/node/ts5.7/index.d.ts +2 -0
  129. package/node_modules/@types/node/url.d.ts +8 -3
  130. package/node_modules/@types/node/util.d.ts +17 -3
  131. package/node_modules/@types/node/v8.d.ts +38 -5
  132. package/node_modules/@types/node/vm.d.ts +169 -88
  133. package/node_modules/@types/node/wasi.d.ts +1 -1
  134. package/node_modules/@types/node/web-globals/crypto.d.ts +32 -0
  135. package/node_modules/@types/node/web-globals/events.d.ts +3 -0
  136. package/node_modules/@types/node/web-globals/streams.d.ts +22 -0
  137. package/node_modules/@types/node/worker_threads.d.ts +109 -48
  138. package/node_modules/@types/node/zlib.d.ts +31 -24
  139. package/node_modules/axios/CHANGELOG.md +403 -357
  140. package/node_modules/axios/README.md +80 -49
  141. package/node_modules/axios/dist/axios.js +121 -46
  142. package/node_modules/axios/dist/axios.js.map +1 -1
  143. package/node_modules/axios/dist/axios.min.js +2 -2
  144. package/node_modules/axios/dist/axios.min.js.map +1 -1
  145. package/node_modules/axios/dist/browser/axios.cjs +126 -57
  146. package/node_modules/axios/dist/browser/axios.cjs.map +1 -1
  147. package/node_modules/axios/dist/esm/axios.js +126 -57
  148. package/node_modules/axios/dist/esm/axios.js.map +1 -1
  149. package/node_modules/axios/dist/esm/axios.min.js +2 -2
  150. package/node_modules/axios/dist/esm/axios.min.js.map +1 -1
  151. package/node_modules/axios/dist/node/axios.cjs +346 -97
  152. package/node_modules/axios/dist/node/axios.cjs.map +1 -1
  153. package/node_modules/axios/index.d.cts +4 -0
  154. package/node_modules/axios/index.d.ts +4 -0
  155. package/node_modules/axios/lib/adapters/adapters.js +85 -40
  156. package/node_modules/axios/lib/adapters/fetch.js +1 -1
  157. package/node_modules/axios/lib/adapters/http.js +220 -42
  158. package/node_modules/axios/lib/core/InterceptorManager.js +1 -1
  159. package/node_modules/axios/lib/core/mergeConfig.js +4 -4
  160. package/node_modules/axios/lib/env/data.js +1 -1
  161. package/node_modules/axios/lib/helpers/HttpStatusCode.js +6 -0
  162. package/node_modules/axios/lib/helpers/bind.js +7 -0
  163. package/node_modules/axios/lib/helpers/cookies.js +24 -13
  164. package/node_modules/axios/package.json +9 -4
  165. package/node_modules/detect-libc/lib/filesystem.js +1 -1
  166. package/node_modules/detect-libc/package.json +3 -1
  167. package/node_modules/node-abi/abi_registry.json +12 -2
  168. package/node_modules/node-abi/package.json +3 -6
  169. package/node_modules/semver/classes/range.js +1 -0
  170. package/node_modules/semver/classes/semver.js +19 -5
  171. package/node_modules/semver/internal/identifiers.js +4 -0
  172. package/node_modules/semver/package.json +3 -3
  173. package/node_modules/undici-types/agent.d.ts +1 -4
  174. package/node_modules/undici-types/client.d.ts +0 -2
  175. package/node_modules/undici-types/diagnostics-channel.d.ts +0 -1
  176. package/node_modules/undici-types/dispatcher.d.ts +0 -6
  177. package/node_modules/undici-types/errors.d.ts +5 -15
  178. package/node_modules/undici-types/eventsource.d.ts +6 -1
  179. package/node_modules/undici-types/h2c-client.d.ts +0 -2
  180. package/node_modules/undici-types/index.d.ts +6 -1
  181. package/node_modules/undici-types/interceptors.d.ts +5 -0
  182. package/node_modules/undici-types/mock-interceptor.d.ts +0 -1
  183. package/node_modules/undici-types/package.json +1 -1
  184. package/node_modules/undici-types/snapshot-agent.d.ts +109 -0
  185. package/node_modules/undici-types/webidl.d.ts +82 -21
  186. package/package.json +3 -3
  187. package/node_modules/@contrast/assess/lib/get-policy.js +0 -336
  188. package/node_modules/@contrast/protect/lib/input-analysis/install/koa-body5.js +0 -63
  189. package/node_modules/@contrast/protect/lib/input-analysis/install/koa-bodyparser4.js +0 -64
@@ -32,21 +32,12 @@ const { createLibData, serializeLibrary, getFileCount } = require('../../util.js
32
32
  */
33
33
 
34
34
  /**
35
- * Formats libraries, and keeps track of nested modules.
36
- *
37
- * @param {Record<string, listInstalled.Result | string>} deps collection of dependencies from app root
38
- * @return {Record<string, FormattedResult>} formatted object
39
- */
40
-
41
- /**
42
- * @param {Record<string, FormattedResult>} deps
43
- * @param {Map<string, ReturnType<createLibData>>} libPathHashMap
35
+ * @param {Map<string, FormattedResult>} deps
36
+ * @param {Map<string, ReturnType<typeof createLibData>>} libPathHashMap
44
37
  * @param {import('@contrast/logger').Logger} logger
45
38
  */
46
39
  const processDependencies = (deps, libPathHashMap, logger) => {
47
-
48
40
  if (deps?.size) deps.forEach((dep) => {
49
-
50
41
  const { name, version } = dep;
51
42
 
52
43
  if (!version) {
@@ -16,6 +16,7 @@
16
16
 
17
17
  const fs = require('fs');
18
18
  const path = require('path');
19
+ const semver = require('semver');
19
20
 
20
21
  const { primordials: { JSONParse } } = require('@contrast/common');
21
22
 
@@ -34,6 +35,7 @@ function parsePackage(filePath, logger) {
34
35
  let pkgInfo;
35
36
  try {
36
37
  pkgInfo = JSONParse(pkg);
38
+ pkgInfo.version = semver.clean(pkgInfo.version, { loose: true });
37
39
  } catch (err) {
38
40
  logger.warn({ err }, 'Error parsing package.json for %s', pkgPath);
39
41
  }
@@ -17,6 +17,7 @@
17
17
  const { readFileSync } = require('fs');
18
18
  const path = require('path');
19
19
  const { fileURLToPath } = require('url');
20
+ const semver = require('semver');
20
21
  const { Event, primordials: { JSONParse } } = require('@contrast/common');
21
22
  const { setCodeEventListener } = require('@contrast/code-events');
22
23
  const { findPackageJsonSync } = require('@contrast/find-package-json');
@@ -53,8 +54,9 @@ module.exports = function init(core) {
53
54
  let info = libInfoMap.get(libDir);
54
55
  if (!info) {
55
56
  const { _shasum, dist, name, version } = JSONParse(readFileSync(manifest, 'utf-8'));
57
+ const cleanVersion = semver.clean(version ?? '', { loose: true }) ?? undefined; // `null` -> `undefined` for backwards compatibility
56
58
  info = {
57
- hash: buildLibraryHash({ _shasum, dist, name, version }),
59
+ hash: buildLibraryHash({ _shasum, dist, name, version: cleanVersion }),
58
60
  names: new Set([relativePath]),
59
61
  };
60
62
  libInfoMap.set(libDir, info);
@@ -45,9 +45,7 @@ function createLibData(data, tags) {
45
45
  };
46
46
  }
47
47
 
48
-
49
48
  function serializeLibrary(library) {
50
-
51
49
  const date = Date.now();
52
50
  return {
53
51
  externalDate: date,
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrast/library-analysis",
3
- "version": "1.47.1",
3
+ "version": "1.49.0",
4
4
  "description": "Handles library reporting and library usage analysis",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "author": "Contrast Security <nodejs@contrastsecurity.com> (https://www.contrastsecurity.com)",
@@ -21,10 +21,10 @@
21
21
  },
22
22
  "dependencies": {
23
23
  "@contrast/code-events": "^4.0.2",
24
- "@contrast/common": "1.37.0",
25
- "@contrast/config": "1.52.1",
24
+ "@contrast/common": "1.38.0",
25
+ "@contrast/config": "1.54.0",
26
26
  "@contrast/find-package-json": "^1.1.0",
27
- "@contrast/logger": "1.30.1",
27
+ "@contrast/logger": "1.32.0",
28
28
  "semver": "^7.6.0"
29
29
  }
30
30
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrast/logger",
3
- "version": "1.30.1",
3
+ "version": "1.32.0",
4
4
  "description": "Centralized logging for Contrast agent services",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "author": "Contrast Security <nodejs@contrastsecurity.com> (https://www.contrastsecurity.com)",
@@ -21,8 +21,8 @@
21
21
  "test": "bash ../scripts/test.sh"
22
22
  },
23
23
  "dependencies": {
24
- "@contrast/common": "1.37.0",
25
- "@contrast/config": "1.52.1",
24
+ "@contrast/common": "1.38.0",
25
+ "@contrast/config": "1.54.0",
26
26
  "pino": "^8.15.0"
27
27
  }
28
28
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrast/metrics",
3
- "version": "1.34.1",
3
+ "version": "1.36.0",
4
4
  "description": "Records and logs route latency",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "author": "Contrast Security <nodejs@contrastsecurity.com> (https://www.contrastsecurity.com)",
@@ -21,10 +21,10 @@
21
21
  "test": "bash ../scripts/test.sh"
22
22
  },
23
23
  "dependencies": {
24
- "@contrast/common": "1.37.0",
25
- "@contrast/config": "1.52.1",
26
- "@contrast/dep-hooks": "1.26.1",
27
- "@contrast/logger": "1.30.1",
28
- "@contrast/patcher": "1.29.1"
24
+ "@contrast/common": "1.38.0",
25
+ "@contrast/config": "1.54.0",
26
+ "@contrast/dep-hooks": "1.28.0",
27
+ "@contrast/logger": "1.32.0",
28
+ "@contrast/patcher": "1.31.0"
29
29
  }
30
30
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrast/patcher",
3
- "version": "1.29.1",
3
+ "version": "1.31.0",
4
4
  "description": "Advanced monkey patching--registers hooks to run in and around functions",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "author": "Contrast Security <nodejs@contrastsecurity.com> (https://www.contrastsecurity.com)",
@@ -20,6 +20,6 @@
20
20
  "test": "bash ../scripts/test.sh"
21
21
  },
22
22
  "dependencies": {
23
- "@contrast/logger": "1.30.1"
23
+ "@contrast/logger": "1.32.0"
24
24
  }
25
25
  }
@@ -28,7 +28,7 @@ module.exports = function(core) {
28
28
  require('./install/express')(core);
29
29
  require('./install/fastify')(core);
30
30
  require('./install/hapi')(core);
31
- require('./install/koa2')(core);
31
+ require('./install/koa')(core);
32
32
  require('./install/restify')(core);
33
33
 
34
34
  errorHandlers.install = function() {
@@ -27,10 +27,10 @@ module.exports = function (core) {
27
27
  protect,
28
28
  } = core;
29
29
 
30
- const koa2ErrorHandler = protect.errorHandlers.koa2ErrorHandler = {};
30
+ const koaErrorHandler = protect.errorHandlers.koaErrorHandler = {};
31
31
 
32
- koa2ErrorHandler.install = function () {
33
- depHooks.resolve({ name: 'koa', version: '>=2.3.0 <3' }, (Koa) => {
32
+ koaErrorHandler.install = function () {
33
+ depHooks.resolve({ name: 'koa', version: '>=2.3.0 <4' }, (Koa) => {
34
34
  patcher.patch(Koa.prototype, 'handleRequest', {
35
35
  name: 'Koa.Application.handleRequest',
36
36
  patchType,
@@ -63,5 +63,5 @@ module.exports = function (core) {
63
63
  });
64
64
  };
65
65
 
66
- return koa2ErrorHandler;
66
+ return koaErrorHandler;
67
67
  };
@@ -122,7 +122,7 @@ export interface Protect {
122
122
  handler: (err: Error, request: IncomingMessage, reply: ServerResponse) => void,
123
123
  install: () => void
124
124
  }
125
- koa2ErrorHandler: { install: () => void },
125
+ koaErrorHandler: { install: () => void },
126
126
  expressErrorHandler: { install: () => void },
127
127
  install: () => void,
128
128
  },
@@ -665,7 +665,6 @@ module.exports = Core.makeComponent({
665
665
  // Detecting probes
666
666
  const rulesMask = sourceContext.policy.getRulesMask();
667
667
  if (rulesMask == 0 || !config.protect.probe_analysis.enable) return;
668
- const probeReports = [];
669
668
  const { resultsMap } = sourceContext;
670
669
  const probesRules = [Rule.CMD_INJECTION, Rule.PATH_TRAVERSAL, Rule.SQL_INJECTION, Rule.XXE];
671
670
  const probes = {};
@@ -734,7 +733,6 @@ module.exports = Core.makeComponent({
734
733
  }) || [];
735
734
  alibResult.forEach(result => {
736
735
  results.push({ value, ...result });
737
- probeReports.push({ value, ...result });
738
736
  valueToResultByRuleId[value] = resultByRuleId;
739
737
  });
740
738
  });
@@ -756,16 +754,7 @@ module.exports = Core.makeComponent({
756
754
  probes[key] = probe;
757
755
  });
758
756
 
759
- Object.values(probes).forEach(probe => {
760
- if (!resultsMap[probe.ruleId]) {
761
- resultsMap[probe.ruleId] = [];
762
- }
763
-
764
- resultsMap[probe.ruleId].push(probe);
765
- probeReports.push(probe);
766
- });
767
-
768
- for (const result of probeReports) {
757
+ for (const result of Object.values(probes)) {
769
758
  core.protect.reportFinding({ result });
770
759
  }
771
760
  };
@@ -30,15 +30,14 @@ module.exports = function(core) {
30
30
  require('./install/body-parser')(core);
31
31
  require('./install/cookie-parser1')(core);
32
32
  require('./install/formidable1')(core);
33
- require('./install/koa-body5')(core);
34
- require('./install/koa-bodyparser4')(core);
33
+ require('./install/koa-bodyparsers')(core);
35
34
  require('./install/multer1')(core);
36
35
  require('./install/qs6')(core);
37
36
  require('./install/universal-cookie4')(core);
38
37
 
39
38
  // framework specific instrumentation
40
39
  require('./install/fastify')(core);
41
- require('./install/koa2')(core);
40
+ require('./install/koa')(core);
42
41
  require('./install/express')(core);
43
42
  require('./install/hapi')(core);
44
43
  require('./install/restify')(core);
@@ -0,0 +1,92 @@
1
+ /*
2
+ * Copyright: 2025 Contrast Security, Inc
3
+ * Contact: support@contrastsecurity.com
4
+ * License: Commercial
5
+
6
+ * NOTICE: This Software and the patented inventions embodied within may only be
7
+ * used as part of Contrast Security’s commercial offerings. Even though it is
8
+ * made available through public repositories, use of this Software is subject to
9
+ * the applicable End User Licensing Agreement found at
10
+ * https://www.contrastsecurity.com/enduser-terms-0317a or as otherwise agreed
11
+ * between Contrast Security and the End User. The Software may not be reverse
12
+ * engineered, modified, repackaged, sold, redistributed or otherwise used in a
13
+ * way not consistent with the End User License Agreement.
14
+ */
15
+
16
+ 'use strict';
17
+
18
+ const { patchType } = require('../constants');
19
+
20
+ module.exports = (core) => {
21
+ const {
22
+ depHooks,
23
+ patcher,
24
+ protect,
25
+ protect: { inputAnalysis },
26
+ } = core;
27
+
28
+ function postFn(name) {
29
+ return function(data) {
30
+ data.result = patcher.patch(data.result, {
31
+ name,
32
+ patchType,
33
+ pre(data) {
34
+ const [ctx, origNext] = data.args;
35
+
36
+ async function contrastNext(origErr) {
37
+ const sourceContext = protect.getSourceContext();
38
+
39
+
40
+ if (sourceContext && ctx.request.body && Object.keys(ctx.request.body).length) {
41
+ sourceContext.parsedBody = ctx.request.body;
42
+ inputAnalysis.handleParsedBody(sourceContext, ctx.request.body);
43
+ }
44
+
45
+ await origNext(origErr);
46
+ }
47
+
48
+ data.args[1] = contrastNext;
49
+ }
50
+ });
51
+ };
52
+ }
53
+
54
+ function install() {
55
+ [['koa-body', '>=4 <6'], ['koa-bodyparser', '>=4 <5']].forEach(([name, version]) => {
56
+ depHooks.resolve({ name, version }, (koaBody) =>
57
+ patcher.patch(koaBody, {
58
+ name,
59
+ patchType,
60
+ post: postFn(name)
61
+ })
62
+ );
63
+ });
64
+
65
+ depHooks.resolve({ name: 'koa-body', version: '>=6 <7' }, (koaBody) =>
66
+ patcher.patch(koaBody, 'koaBody', {
67
+ name: 'koaBody',
68
+ patchType,
69
+ post: postFn('koa-body')
70
+ })
71
+ );
72
+
73
+ depHooks.resolve({ name: '@koa/bodyparser', version: '>=5 <7' }, (koaBody) => {
74
+ const patchedBodyParser = patcher.patch(koaBody.bodyParser, {
75
+ name: '@koa/bodyparser',
76
+ patchType,
77
+ post: postFn('@koa/bodyparser')
78
+ }
79
+ );
80
+ return {
81
+ default: patchedBodyParser,
82
+ bodyParser: patchedBodyParser
83
+ };
84
+ });
85
+ }
86
+
87
+ const koaBodyparserInstrumentation = inputAnalysis.koaBodyparserInstrumentation = {
88
+ install
89
+ };
90
+
91
+ return koaBodyparserInstrumentation;
92
+ };
@@ -34,7 +34,7 @@ module.exports = (core) => {
34
34
  * registers a depHook for koa module instrumentation
35
35
  */
36
36
  function install() {
37
- depHooks.resolve({ name: 'koa', version: '>=2.3.0 <3' }, (Koa) => {
37
+ depHooks.resolve({ name: 'koa', version: '>=2.3.0 <4' }, (Koa) => {
38
38
  function contrastStartMiddleware(ctx, next) {
39
39
  if (ctx.query && Object.keys(ctx.query).length) {
40
40
  const sourceContext = protect.getSourceContext();
@@ -65,11 +65,11 @@ module.exports = (core) => {
65
65
  });
66
66
 
67
67
  // Patch `koa-router` and `@koa/router` to handle parsed params
68
- [['koa-router', '<14'], ['@koa/router', '<14']].forEach(([router, version]) => {
68
+ [['koa-router', '>=12 <15'], ['@koa/router', '>=12 <15']].forEach(([router, version]) => {
69
69
  depHooks.resolve(
70
70
  { name: router, version, file: 'lib/layer.js' },
71
71
  (layer) => {
72
- layer.prototype = patcher.patch(layer.prototype, 'params', {
72
+ patcher.patch(layer.prototype, 'params', {
73
73
  name: `[${router}].layer.prototype`,
74
74
  patchType,
75
75
  post({ result }) {
@@ -119,9 +119,9 @@ module.exports = (core) => {
119
119
  });
120
120
  }
121
121
 
122
- const koa2Instrumentation = inputAnalysis.koa2Instrumentation = {
122
+ const koaInstrumentation = inputAnalysis.koaInstrumentation = {
123
123
  install
124
124
  };
125
125
 
126
- return koa2Instrumentation;
126
+ return koaInstrumentation;
127
127
  };
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrast/protect",
3
- "version": "1.68.0",
3
+ "version": "1.70.0",
4
4
  "description": "Contrast service providing framework-agnostic Protect 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/agent-lib": "^9.1.0",
24
- "@contrast/common": "1.37.0",
25
- "@contrast/config": "1.52.1",
26
- "@contrast/core": "1.57.1",
27
- "@contrast/dep-hooks": "1.26.1",
28
- "@contrast/esm-hooks": "2.32.0",
29
- "@contrast/instrumentation": "1.36.1",
30
- "@contrast/logger": "1.30.1",
31
- "@contrast/patcher": "1.29.1",
32
- "@contrast/rewriter": "1.34.0",
33
- "@contrast/scopes": "1.27.1",
24
+ "@contrast/common": "1.38.0",
25
+ "@contrast/config": "1.54.0",
26
+ "@contrast/core": "1.59.0",
27
+ "@contrast/dep-hooks": "1.28.0",
28
+ "@contrast/esm-hooks": "2.34.0",
29
+ "@contrast/instrumentation": "1.38.0",
30
+ "@contrast/logger": "1.32.0",
31
+ "@contrast/patcher": "1.31.0",
32
+ "@contrast/rewriter": "1.36.0",
33
+ "@contrast/scopes": "1.29.0",
34
34
  "async-hook-domain": "^4.0.1",
35
35
  "ipaddr.js": "^2.0.1",
36
36
  "on-finished": "^2.4.1",
@@ -177,17 +177,15 @@ class Translations {
177
177
  }
178
178
  buildRequestObject(sourceInfo, masker) {
179
179
  const searchParams = new URLSearchParams(sourceInfo.queries);
180
- const parameters = {};
180
+ const parameters = Object.create(null);
181
181
  for (const [key, value] of searchParams) {
182
- const redacted = masker.getMaskedValue(key, value);
183
- if (parameters[key]) {
184
- parameters[key].push(redacted);
185
- }
186
- else {
187
- parameters[key] = [redacted];
182
+ if (!parameters[key] || !Array.isArray(parameters[key])) {
183
+ parameters[key] = [];
188
184
  }
185
+ const redacted = masker.getMaskedValue(key, value);
186
+ parameters[key].push(redacted);
189
187
  }
190
- const headers = {};
188
+ const headers = Object.create(null);
191
189
  for (let i = 0; i < sourceInfo.rawHeaders.length; i += 2) {
192
190
  const key = sourceInfo.rawHeaders[i];
193
191
  const redactedValue = masker.getMaskedValue(key, sourceInfo.rawHeaders[i + 1]);
@@ -202,7 +200,6 @@ class Translations {
202
200
  headers,
203
201
  };
204
202
  }
205
- ;
206
203
  accumulateUserAgent(set, eventArg) {
207
204
  const userAgent = eventArg.store.sourceInfo?.getHeader?.('user-agent');
208
205
  if (userAgent)
@@ -302,5 +299,4 @@ class Translations {
302
299
  }
303
300
  }
304
301
  exports.Translations = Translations;
305
- ;
306
302
  //# sourceMappingURL=translations.js.map
@@ -32,6 +32,10 @@ class RoutesObserved extends v1_endpoint_1.default {
32
32
  * Language specific signature of the controller method.
33
33
  */
34
34
  signature: route.signature,
35
+ /**
36
+ * The type of route that is being reported.
37
+ */
38
+ type: route.type,
35
39
  /**
36
40
  * The HTTP verb of this request. The HTTP verb of this request. If one
37
41
  * is not detected, omit this field. TeamServer will treat this as if
@@ -7,7 +7,7 @@ export type AbstractFinding = {
7
7
  properties?: any;
8
8
  ruleId: string;
9
9
  time: number;
10
- routes?: any[];
10
+ routes?: any[] | readonly never[];
11
11
  };
12
12
  export type SourceFindingsAccum = {
13
13
  findings: AbstractFinding[];
@@ -99,7 +99,7 @@ class Traces extends ng_endpoint_1.default {
99
99
  time: Date.now(),
100
100
  });
101
101
  });
102
- this.reporter.subscribeWithLock(common_1.Event.ASSESS_SESSION_CONFIGURATION_FINDING, (msg) => {
102
+ this.reporter.subscribeWithLock(common_1.Event.ASSESS_CONFIGURATION_FINDING, (msg) => {
103
103
  const accum = this.getFindingsAccum(msg);
104
104
  if (!accum)
105
105
  return;
@@ -6,7 +6,7 @@ export declare function getEventHash(traceData: any): number | undefined;
6
6
  export declare function getTraceEvent(event: any, eventDetail?: string): TraceEvent;
7
7
  export declare function getCryptoEvent(finding: any): any;
8
8
  export declare function topologicalSort(sinkEvent: any): any[];
9
- export declare function getRoutes(route: any, prod?: boolean): {
9
+ export declare function getRoutes(route: any, prod?: boolean): readonly never[] | {
10
10
  count: number;
11
11
  observations: {
12
12
  url: any;
@@ -117,10 +117,12 @@ function getTraceEvent(event, eventDetail = 'FULL') {
117
117
  const { stack } = event;
118
118
  if (!event.history) {
119
119
  const context = event.context || `req.${event.inputType}.${event.pathName}`;
120
+ const isWebSocket = event.inputType == common_1.InputType.WEBSOCKET;
121
+ const { args } = event;
120
122
  base = {
121
- args: [{
123
+ args: args ? args : [{
122
124
  tracked: false,
123
- value: (0, common_1.encodeString)(StringPrototypeSubstr.call(context, context.indexOf('.') + 1)),
125
+ value: StringPrototypeSubstr.call(context, context.indexOf('.') + 1),
124
126
  }],
125
127
  // always build source event `context` field no matter what `eventDetail` value is.
126
128
  // the cost is minimal in sources instrumentation and the way the UI builds out method call without it is funky
@@ -129,12 +131,14 @@ function getTraceEvent(event, eventDetail = 'FULL') {
129
131
  fieldName: event.fieldName,
130
132
  object: {
131
133
  tracked: false,
132
- value: (0, common_1.encodeString)(event.object?.value || 'http.IncomingMessage'),
134
+ value: isWebSocket ?
135
+ (event.object?.value || 'Socket') :
136
+ (event.object?.value || 'http.IncomingMessage'),
133
137
  },
134
138
  source: 'P',
135
139
  ret: {
136
140
  tracked: true,
137
- value: (0, common_1.encodeString)(String(event.result.value)),
141
+ value: String(event.result.value),
138
142
  },
139
143
  target: 'R',
140
144
  type: types_1.EventType.PROPAGATION
@@ -144,16 +148,16 @@ function getTraceEvent(event, eventDetail = 'FULL') {
144
148
  base = {
145
149
  args: event.args.map(({ tracked, value }) => ({
146
150
  tracked,
147
- value: (0, common_1.encodeString)(String(value)),
151
+ value: String(value),
148
152
  })),
149
153
  eventSources: [],
150
154
  object: {
151
155
  tracked: event.object.tracked,
152
- value: (0, common_1.encodeString)(String(event.object.value)),
156
+ value: String(event.object.value),
153
157
  },
154
158
  ret: {
155
159
  tracked: event.result.tracked,
156
- value: (0, common_1.encodeString)(String(event.result?.value || '')),
160
+ value: String(event.result?.value || ''),
157
161
  },
158
162
  source: event.source,
159
163
  target: event.target,
@@ -164,6 +168,15 @@ function getTraceEvent(event, eventDetail = 'FULL') {
164
168
  base.context = event.context;
165
169
  }
166
170
  }
171
+ // encode call context values
172
+ base.object.value = (0, common_1.encodeString)(base.object.value);
173
+ base.ret.value = (0, common_1.encodeString)(base.ret.value);
174
+ // TS appears to handle WEBSOCKET args differently
175
+ if (event.inputType !== common_1.InputType.WEBSOCKET) {
176
+ for (const arg of base.args) {
177
+ arg.value = (0, common_1.encodeString)(arg.value);
178
+ }
179
+ }
167
180
  return {
168
181
  ...base,
169
182
  action,
@@ -230,7 +243,7 @@ function sorter(a, b) {
230
243
  return lengthFactor + timeFactor;
231
244
  }
232
245
  function getRoutes(route, prod) {
233
- return [{
246
+ return !route ? common_1.empties.ARRAY : [{
234
247
  count: 1,
235
248
  observations: [{
236
249
  url: prod ? route.normalizedUrl : route.url,
@@ -292,7 +305,7 @@ function getRequest(store, prod) {
292
305
  protocol: store.sourceInfo?.protocol,
293
306
  queryString,
294
307
  uri,
295
- standardNormalizedUri: route?.normalizedUrl,
308
+ standardNormalizedUri: route?.normalizedUri ?? store.sourceInfo?.normalizedUri,
296
309
  version: httpVersion,
297
310
  };
298
311
  if (prod) {
@@ -35,7 +35,7 @@ class FileReporter extends base_1.default {
35
35
  common_1.Event.ASSESS_DATAFLOW_FINDING,
36
36
  common_1.Event.ASSESS_DATAFLOW_SAFE_POSITIVE,
37
37
  common_1.Event.ASSESS_RESPONSE_SCANNING_FINDING,
38
- common_1.Event.ASSESS_SESSION_CONFIGURATION_FINDING,
38
+ common_1.Event.ASSESS_CONFIGURATION_FINDING,
39
39
  common_1.Event.ASSESS_CRYPTO_ANALYSIS_FINDING,
40
40
  common_1.Event.LIBRARY_USAGE,
41
41
  common_1.Event.LIBRARY,
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrast/reporter",
3
- "version": "1.55.1",
3
+ "version": "1.57.0",
4
4
  "description": "Subscribes to agent messages and reports them",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "author": "Contrast Security <nodejs@contrastsecurity.com> (https://www.contrastsecurity.com)",
@@ -21,12 +21,12 @@
21
21
  "test": "bash ../scripts/test.sh"
22
22
  },
23
23
  "dependencies": {
24
- "@contrast/common": "1.37.0",
25
- "@contrast/config": "1.52.1",
26
- "@contrast/core": "1.57.1",
27
- "@contrast/logger": "1.30.1",
24
+ "@contrast/common": "1.38.0",
25
+ "@contrast/config": "1.54.0",
26
+ "@contrast/core": "1.59.0",
27
+ "@contrast/logger": "1.32.0",
28
28
  "@contrast/perf": "1.4.0",
29
- "@contrast/scopes": "1.27.1",
29
+ "@contrast/scopes": "1.29.0",
30
30
  "axios": "^1.12.2",
31
31
  "crc-32": "^1.2.2",
32
32
  "safe-stable-stringify": "^2.4.1",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrast/rewriter",
3
- "version": "1.34.0",
3
+ "version": "1.36.0",
4
4
  "description": "A transpilation tool mainly used for instrumentation",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "author": "Contrast Security <nodejs@contrastsecurity.com> (https://www.contrastsecurity.com)",
@@ -21,10 +21,10 @@
21
21
  },
22
22
  "dependencies": {
23
23
  "@contrast/agent-swc-plugin": "3.2.0",
24
- "@contrast/common": "1.37.0",
25
- "@contrast/config": "1.52.1",
26
- "@contrast/core": "1.57.1",
27
- "@contrast/logger": "1.30.1",
24
+ "@contrast/common": "1.38.0",
25
+ "@contrast/config": "1.54.0",
26
+ "@contrast/core": "1.59.0",
27
+ "@contrast/logger": "1.32.0",
28
28
  "@swc/core": "1.13.3"
29
29
  }
30
30
  }
@@ -23,13 +23,11 @@ import { Scopes } from '@contrast/scopes';
23
23
  export { RouteInfo };
24
24
 
25
25
  export interface RouteCoverage extends Installable {
26
- _normalizedUrlMapper: any;
27
26
  discover(info: RouteInfo): void;
28
27
  discoveryFinished(): void;
29
28
  queue(info: RouteInfo): void;
30
29
  queuingFinished(): void;
31
30
  observe(info: RouteInfo): void;
32
- uriPathToNormalizedUrl(uriPath: string): string;
33
31
  }
34
32
 
35
33
  export interface Core {