@contrast/agent-bundle 5.39.1 → 5.41.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 (279) hide show
  1. package/node_modules/@contrast/agent/lib/start-agent.js +50 -40
  2. package/node_modules/@contrast/agent/package.json +11 -11
  3. package/node_modules/@contrast/agent-swc-plugin/index.js +9 -3
  4. package/node_modules/@contrast/agent-swc-plugin/methods.js +15 -1
  5. package/node_modules/@contrast/agent-swc-plugin/package.json +5 -8
  6. package/node_modules/@contrast/agent-swc-plugin/rewriter.wasm +0 -0
  7. package/node_modules/@contrast/agentify/lib/index.js +2 -2
  8. package/node_modules/@contrast/agentify/package.json +15 -14
  9. package/node_modules/@contrast/architecture-components/package.json +5 -5
  10. package/node_modules/@contrast/assess/lib/dataflow/propagation/install/string/replace.js +6 -3
  11. package/node_modules/@contrast/assess/lib/dataflow/propagation/install/util-format.js +44 -21
  12. package/node_modules/@contrast/assess/lib/dataflow/sources/index.js +1 -1
  13. package/node_modules/@contrast/assess/lib/dataflow/sources/install/{body-parser1.js → body-parser.js} +2 -2
  14. package/node_modules/@contrast/assess/lib/dataflow/sources/install/koa/koa-bodyparsers.js +3 -1
  15. package/node_modules/@contrast/assess/lib/dataflow/sources/install/qs6.js +5 -5
  16. package/node_modules/@contrast/assess/lib/dataflow/sources/install/querystring.js +2 -1
  17. package/node_modules/@contrast/assess/lib/index.d.ts +0 -1
  18. package/node_modules/@contrast/assess/lib/make-source-context.js +7 -37
  19. package/node_modules/@contrast/assess/lib/sampler/common.js +7 -11
  20. package/node_modules/@contrast/assess/package.json +12 -11
  21. package/node_modules/@contrast/common/lib/constants.d.ts +6 -0
  22. package/node_modules/@contrast/common/lib/constants.js +8 -1
  23. package/node_modules/@contrast/common/lib/types.d.ts +7 -1
  24. package/node_modules/@contrast/common/package.json +1 -1
  25. package/node_modules/@contrast/config/lib/common.js +1 -1
  26. package/node_modules/@contrast/config/lib/config.js +49 -27
  27. package/node_modules/@contrast/config/lib/index.d.ts +3 -2
  28. package/node_modules/@contrast/config/lib/options.js +4 -4
  29. package/node_modules/@contrast/config/package.json +4 -3
  30. package/node_modules/@contrast/core/lib/sensitive-data-masking/protect-listener.js +15 -15
  31. package/node_modules/@contrast/core/package.json +6 -6
  32. package/node_modules/@contrast/deadzones/package.json +5 -5
  33. package/node_modules/@contrast/dep-hooks/package.json +3 -3
  34. package/node_modules/@contrast/esm-hooks/package.json +6 -6
  35. package/node_modules/@contrast/instrumentation/lib/index.js +0 -1
  36. package/node_modules/@contrast/instrumentation/package.json +5 -5
  37. package/node_modules/@contrast/library-analysis/lib/install/library-reporting/dep.json +300 -152
  38. package/node_modules/@contrast/library-analysis/lib/install/library-reporting/index.js +9 -2
  39. package/node_modules/@contrast/library-analysis/lib/install/library-reporting/utils.js +54 -43
  40. package/node_modules/@contrast/library-analysis/package.json +4 -4
  41. package/node_modules/@contrast/logger/lib/serializers.js +2 -2
  42. package/node_modules/@contrast/logger/package.json +3 -3
  43. package/node_modules/@contrast/metrics/package.json +6 -6
  44. package/node_modules/@contrast/patcher/package.json +2 -2
  45. package/node_modules/@contrast/protect/lib/get-source-context.js +3 -1
  46. package/node_modules/@contrast/protect/lib/index.js +6 -1
  47. package/node_modules/@contrast/protect/lib/input-analysis/handlers.js +7 -9
  48. package/node_modules/@contrast/protect/lib/input-analysis/index.js +1 -1
  49. package/node_modules/@contrast/protect/lib/input-analysis/install/{body-parser1.js → body-parser.js} +1 -1
  50. package/node_modules/@contrast/protect/lib/input-analysis/install/http.js +18 -19
  51. package/node_modules/@contrast/protect/lib/input-analysis/install/qs6.js +18 -17
  52. package/node_modules/@contrast/protect/lib/input-analysis/install/universal-cookie4.js +2 -3
  53. package/node_modules/@contrast/protect/lib/make-source-context.js +22 -66
  54. package/node_modules/@contrast/protect/lib/semantic-analysis/handlers.js +73 -72
  55. package/node_modules/@contrast/protect/package.json +11 -11
  56. package/node_modules/@contrast/reporter/lib/reporters/contrast-ui/endpoints/application-activity/index.js +7 -7
  57. package/node_modules/@contrast/reporter/lib/reporters/contrast-ui/endpoints/application-activity/translations.d.ts +3 -3
  58. package/node_modules/@contrast/reporter/lib/reporters/contrast-ui/endpoints/application-activity/translations.js +24 -21
  59. package/node_modules/@contrast/reporter/lib/reporters/contrast-ui/endpoints/routes-observed.js +2 -1
  60. package/node_modules/@contrast/reporter/lib/reporters/contrast-ui/endpoints/traces/index.js +1 -1
  61. package/node_modules/@contrast/reporter/lib/reporters/contrast-ui/endpoints/traces/translations.d.ts +1 -2
  62. package/node_modules/@contrast/reporter/lib/reporters/contrast-ui/endpoints/traces/translations.js +8 -2
  63. package/node_modules/@contrast/reporter/lib/reporters/security-logger/index.d.ts +2 -2
  64. package/node_modules/@contrast/reporter/lib/reporters/security-logger/index.js +22 -20
  65. package/node_modules/@contrast/reporter/package.json +7 -7
  66. package/node_modules/@contrast/rewriter/lib/index.js +2 -2
  67. package/node_modules/@contrast/rewriter/package.json +6 -6
  68. package/node_modules/@contrast/route-coverage/lib/index.d.ts +2 -0
  69. package/node_modules/@contrast/route-coverage/lib/index.js +15 -17
  70. package/node_modules/@contrast/route-coverage/lib/install/express/express5.js +489 -202
  71. package/node_modules/@contrast/route-coverage/package.json +9 -9
  72. package/node_modules/@contrast/scopes/package.json +5 -5
  73. package/node_modules/@contrast/sec-obs/lib/traces/http.js +2 -2
  74. package/node_modules/@contrast/sec-obs/lib/traces/http.test.js +17 -0
  75. package/node_modules/@contrast/sec-obs/lib/traces/outbound-service-call.js +2 -2
  76. package/node_modules/@contrast/sec-obs/lib/traces/outbound-service-call.test.js +17 -0
  77. package/node_modules/@contrast/sec-obs/package.json +9 -9
  78. package/node_modules/@contrast/sources/lib/index.js +109 -0
  79. package/node_modules/@contrast/sources/lib/index.test.js +120 -0
  80. package/node_modules/@contrast/{route-coverage/lib/normalized-url-mapper.js → sources/lib/normalized-uri-mapper.js} +10 -3
  81. package/node_modules/@contrast/sources/lib/normalized-uri-mapper.test.js +59 -0
  82. package/node_modules/@contrast/{sec-obs/node_modules/@contrast/core/lib/sensitive-data-masking/constants.js → sources/lib/req-data.js} +0 -6
  83. package/node_modules/@contrast/sources/lib/source-info.js +183 -0
  84. package/node_modules/@contrast/sources/lib/source-info.test.js +68 -0
  85. package/node_modules/@contrast/sources/package.json +16 -0
  86. package/node_modules/@contrast/telemetry/package.json +6 -6
  87. package/node_modules/@opentelemetry/semantic-conventions/build/esm/experimental_attributes.d.ts +2831 -77
  88. package/node_modules/@opentelemetry/semantic-conventions/build/esm/experimental_attributes.js +2831 -77
  89. package/node_modules/@opentelemetry/semantic-conventions/build/esm/experimental_attributes.js.map +1 -1
  90. package/node_modules/@opentelemetry/semantic-conventions/build/esm/experimental_metrics.d.ts +415 -98
  91. package/node_modules/@opentelemetry/semantic-conventions/build/esm/experimental_metrics.js +415 -98
  92. package/node_modules/@opentelemetry/semantic-conventions/build/esm/experimental_metrics.js.map +1 -1
  93. package/node_modules/@opentelemetry/semantic-conventions/build/esm/stable_attributes.d.ts +106 -0
  94. package/node_modules/@opentelemetry/semantic-conventions/build/esm/stable_attributes.js +106 -0
  95. package/node_modules/@opentelemetry/semantic-conventions/build/esm/stable_attributes.js.map +1 -1
  96. package/node_modules/@opentelemetry/semantic-conventions/build/esm/version.d.ts +1 -1
  97. package/node_modules/@opentelemetry/semantic-conventions/build/esm/version.js +1 -1
  98. package/node_modules/@opentelemetry/semantic-conventions/build/esm/version.js.map +1 -1
  99. package/node_modules/@opentelemetry/semantic-conventions/build/esnext/experimental_attributes.d.ts +2831 -77
  100. package/node_modules/@opentelemetry/semantic-conventions/build/esnext/experimental_attributes.js +2831 -77
  101. package/node_modules/@opentelemetry/semantic-conventions/build/esnext/experimental_attributes.js.map +1 -1
  102. package/node_modules/@opentelemetry/semantic-conventions/build/esnext/experimental_metrics.d.ts +415 -98
  103. package/node_modules/@opentelemetry/semantic-conventions/build/esnext/experimental_metrics.js +415 -98
  104. package/node_modules/@opentelemetry/semantic-conventions/build/esnext/experimental_metrics.js.map +1 -1
  105. package/node_modules/@opentelemetry/semantic-conventions/build/esnext/stable_attributes.d.ts +106 -0
  106. package/node_modules/@opentelemetry/semantic-conventions/build/esnext/stable_attributes.js +106 -0
  107. package/node_modules/@opentelemetry/semantic-conventions/build/esnext/stable_attributes.js.map +1 -1
  108. package/node_modules/@opentelemetry/semantic-conventions/build/esnext/version.d.ts +1 -1
  109. package/node_modules/@opentelemetry/semantic-conventions/build/esnext/version.js +1 -1
  110. package/node_modules/@opentelemetry/semantic-conventions/build/esnext/version.js.map +1 -1
  111. package/node_modules/@opentelemetry/semantic-conventions/build/src/experimental_attributes.d.ts +2831 -77
  112. package/node_modules/@opentelemetry/semantic-conventions/build/src/experimental_attributes.js +2858 -103
  113. package/node_modules/@opentelemetry/semantic-conventions/build/src/experimental_attributes.js.map +1 -1
  114. package/node_modules/@opentelemetry/semantic-conventions/build/src/experimental_metrics.d.ts +415 -98
  115. package/node_modules/@opentelemetry/semantic-conventions/build/src/experimental_metrics.js +420 -102
  116. package/node_modules/@opentelemetry/semantic-conventions/build/src/experimental_metrics.js.map +1 -1
  117. package/node_modules/@opentelemetry/semantic-conventions/build/src/stable_attributes.d.ts +106 -0
  118. package/node_modules/@opentelemetry/semantic-conventions/build/src/stable_attributes.js +106 -0
  119. package/node_modules/@opentelemetry/semantic-conventions/build/src/stable_attributes.js.map +1 -1
  120. package/node_modules/@opentelemetry/semantic-conventions/build/src/version.d.ts +1 -1
  121. package/node_modules/@opentelemetry/semantic-conventions/build/src/version.js +1 -1
  122. package/node_modules/@opentelemetry/semantic-conventions/build/src/version.js.map +1 -1
  123. package/node_modules/@opentelemetry/semantic-conventions/package.json +3 -3
  124. package/node_modules/@types/node/README.md +2 -2
  125. package/node_modules/@types/node/buffer.d.ts +5 -0
  126. package/node_modules/@types/node/dns/promises.d.ts +11 -10
  127. package/node_modules/@types/node/dns.d.ts +18 -19
  128. package/node_modules/@types/node/fs.d.ts +13 -1
  129. package/node_modules/@types/node/http.d.ts +4 -19
  130. package/node_modules/@types/node/inspector.d.ts +53 -0
  131. package/node_modules/@types/node/package.json +2 -82
  132. package/node_modules/@types/node/stream/web.d.ts +4 -0
  133. package/node_modules/axios/CHANGELOG.md +17 -0
  134. package/node_modules/axios/README.md +1 -4
  135. package/node_modules/axios/dist/axios.js +39 -5
  136. package/node_modules/axios/dist/axios.js.map +1 -1
  137. package/node_modules/axios/dist/axios.min.js +2 -2
  138. package/node_modules/axios/dist/axios.min.js.map +1 -1
  139. package/node_modules/axios/dist/browser/axios.cjs +46 -9
  140. package/node_modules/axios/dist/browser/axios.cjs.map +1 -1
  141. package/node_modules/axios/dist/esm/axios.js +46 -9
  142. package/node_modules/axios/dist/esm/axios.js.map +1 -1
  143. package/node_modules/axios/dist/esm/axios.min.js +2 -2
  144. package/node_modules/axios/dist/esm/axios.min.js.map +1 -1
  145. package/node_modules/axios/dist/node/axios.cjs +46 -9
  146. package/node_modules/axios/dist/node/axios.cjs.map +1 -1
  147. package/node_modules/axios/index.d.cts +13 -2
  148. package/node_modules/axios/lib/core/Axios.js +2 -2
  149. package/node_modules/axios/lib/core/mergeConfig.js +1 -1
  150. package/node_modules/axios/lib/env/data.js +1 -1
  151. package/node_modules/axios/lib/helpers/throttle.js +1 -1
  152. package/node_modules/axios/lib/helpers/toURLEncodedForm.js +4 -3
  153. package/node_modules/axios/lib/utils.js +36 -0
  154. package/node_modules/axios/package.json +5 -5
  155. package/node_modules/deepmerge/.editorconfig +7 -0
  156. package/node_modules/deepmerge/.eslintcache +1 -0
  157. package/node_modules/deepmerge/changelog.md +167 -0
  158. package/node_modules/deepmerge/dist/cjs.js +133 -0
  159. package/node_modules/deepmerge/dist/umd.js +139 -0
  160. package/node_modules/deepmerge/index.d.ts +20 -0
  161. package/node_modules/deepmerge/index.js +106 -0
  162. package/node_modules/{path-to-regexp/LICENSE → deepmerge/license.txt} +1 -1
  163. package/node_modules/deepmerge/package.json +42 -0
  164. package/node_modules/deepmerge/readme.md +264 -0
  165. package/node_modules/deepmerge/rollup.config.js +22 -0
  166. package/node_modules/follow-redirects/package.json +1 -1
  167. package/node_modules/form-data/CHANGELOG.md +601 -0
  168. package/node_modules/form-data/{Readme.md → README.md} +4 -4
  169. package/node_modules/form-data/lib/form_data.js +2 -6
  170. package/node_modules/form-data/package.json +22 -6
  171. package/node_modules/nan/.github/workflows/ci.yml +8 -10
  172. package/node_modules/nan/.pre-commit-config.yaml +8 -0
  173. package/node_modules/nan/CHANGELOG.md +5 -1
  174. package/node_modules/nan/README.md +4 -4
  175. package/node_modules/nan/nan.h +16 -12
  176. package/node_modules/nan/nan_callbacks.h +13 -0
  177. package/node_modules/nan/nan_callbacks_12_inl.h +16 -2
  178. package/node_modules/nan/nan_callbacks_pre_12_inl.h +6 -2
  179. package/node_modules/nan/nan_maybe_43_inl.h +1 -1
  180. package/node_modules/nan/nan_maybe_pre_43_inl.h +1 -1
  181. package/node_modules/nan/nan_scriptorigin.h +11 -9
  182. package/node_modules/nan/nan_typedarray_contents.h +1 -1
  183. package/node_modules/nan/package.json +2 -2
  184. package/package.json +5 -3
  185. package/node_modules/@contrast/agentify/lib/sources.js +0 -94
  186. package/node_modules/@contrast/route-coverage/lib/install/http.js +0 -44
  187. package/node_modules/@contrast/sec-obs/node_modules/@contrast/common/LICENSE +0 -12
  188. package/node_modules/@contrast/sec-obs/node_modules/@contrast/common/lib/constants.d.ts +0 -385
  189. package/node_modules/@contrast/sec-obs/node_modules/@contrast/common/lib/constants.js +0 -270
  190. package/node_modules/@contrast/sec-obs/node_modules/@contrast/common/lib/index.d.ts +0 -40
  191. package/node_modules/@contrast/sec-obs/node_modules/@contrast/common/lib/index.js +0 -228
  192. package/node_modules/@contrast/sec-obs/node_modules/@contrast/common/lib/primordials.d.ts +0 -65
  193. package/node_modules/@contrast/sec-obs/node_modules/@contrast/common/lib/primordials.js +0 -66
  194. package/node_modules/@contrast/sec-obs/node_modules/@contrast/common/lib/types.d.ts +0 -383
  195. package/node_modules/@contrast/sec-obs/node_modules/@contrast/common/lib/types.js +0 -30
  196. package/node_modules/@contrast/sec-obs/node_modules/@contrast/common/package.json +0 -23
  197. package/node_modules/@contrast/sec-obs/node_modules/@contrast/config/LICENSE +0 -12
  198. package/node_modules/@contrast/sec-obs/node_modules/@contrast/config/README.md +0 -44
  199. package/node_modules/@contrast/sec-obs/node_modules/@contrast/config/lib/common.js +0 -131
  200. package/node_modules/@contrast/sec-obs/node_modules/@contrast/config/lib/config.js +0 -290
  201. package/node_modules/@contrast/sec-obs/node_modules/@contrast/config/lib/index.d.ts +0 -328
  202. package/node_modules/@contrast/sec-obs/node_modules/@contrast/config/lib/index.js +0 -29
  203. package/node_modules/@contrast/sec-obs/node_modules/@contrast/config/lib/options.js +0 -836
  204. package/node_modules/@contrast/sec-obs/node_modules/@contrast/config/lib/validators.js +0 -23
  205. package/node_modules/@contrast/sec-obs/node_modules/@contrast/config/package.json +0 -27
  206. package/node_modules/@contrast/sec-obs/node_modules/@contrast/core/LICENSE +0 -12
  207. package/node_modules/@contrast/sec-obs/node_modules/@contrast/core/README.md +0 -98
  208. package/node_modules/@contrast/sec-obs/node_modules/@contrast/core/lib/agent-info.js +0 -36
  209. package/node_modules/@contrast/sec-obs/node_modules/@contrast/core/lib/app-info.js +0 -233
  210. package/node_modules/@contrast/sec-obs/node_modules/@contrast/core/lib/build-id.js +0 -51
  211. package/node_modules/@contrast/sec-obs/node_modules/@contrast/core/lib/capture-stacktrace.js +0 -256
  212. package/node_modules/@contrast/sec-obs/node_modules/@contrast/core/lib/contrast-methods.js +0 -155
  213. package/node_modules/@contrast/sec-obs/node_modules/@contrast/core/lib/index.d.ts +0 -52
  214. package/node_modules/@contrast/sec-obs/node_modules/@contrast/core/lib/ioc/core.js +0 -95
  215. package/node_modules/@contrast/sec-obs/node_modules/@contrast/core/lib/is-agent-path.js +0 -37
  216. package/node_modules/@contrast/sec-obs/node_modules/@contrast/core/lib/messages.js +0 -28
  217. package/node_modules/@contrast/sec-obs/node_modules/@contrast/core/lib/sensitive-data-masking/index.js +0 -63
  218. package/node_modules/@contrast/sec-obs/node_modules/@contrast/core/lib/sensitive-data-masking/protect-listener.js +0 -111
  219. package/node_modules/@contrast/sec-obs/node_modules/@contrast/core/lib/sensitive-data-masking/server-settings-listener.js +0 -44
  220. package/node_modules/@contrast/sec-obs/node_modules/@contrast/core/lib/system-info/cloud-provider-metadata.js +0 -146
  221. package/node_modules/@contrast/sec-obs/node_modules/@contrast/core/lib/system-info/index.js +0 -225
  222. package/node_modules/@contrast/sec-obs/node_modules/@contrast/core/lib/system-info/linux-os-info.js +0 -137
  223. package/node_modules/@contrast/sec-obs/node_modules/@contrast/core/lib/system-info/utils.js +0 -35
  224. package/node_modules/@contrast/sec-obs/node_modules/@contrast/core/package.json +0 -33
  225. package/node_modules/@contrast/sec-obs/node_modules/@contrast/dep-hooks/LICENSE +0 -12
  226. package/node_modules/@contrast/sec-obs/node_modules/@contrast/dep-hooks/README.md +0 -94
  227. package/node_modules/@contrast/sec-obs/node_modules/@contrast/dep-hooks/lib/export-handler-registry.d.ts +0 -121
  228. package/node_modules/@contrast/sec-obs/node_modules/@contrast/dep-hooks/lib/export-handler-registry.js +0 -206
  229. package/node_modules/@contrast/sec-obs/node_modules/@contrast/dep-hooks/lib/export-hook-descriptor.d.ts +0 -72
  230. package/node_modules/@contrast/sec-obs/node_modules/@contrast/dep-hooks/lib/export-hook-descriptor.js +0 -88
  231. package/node_modules/@contrast/sec-obs/node_modules/@contrast/dep-hooks/lib/handler-invoker.d.ts +0 -46
  232. package/node_modules/@contrast/sec-obs/node_modules/@contrast/dep-hooks/lib/handler-invoker.js +0 -106
  233. package/node_modules/@contrast/sec-obs/node_modules/@contrast/dep-hooks/lib/helpers.d.ts +0 -28
  234. package/node_modules/@contrast/sec-obs/node_modules/@contrast/dep-hooks/lib/helpers.js +0 -66
  235. package/node_modules/@contrast/sec-obs/node_modules/@contrast/dep-hooks/lib/index.d.ts +0 -115
  236. package/node_modules/@contrast/sec-obs/node_modules/@contrast/dep-hooks/lib/index.js +0 -208
  237. package/node_modules/@contrast/sec-obs/node_modules/@contrast/dep-hooks/lib/package-finder.d.ts +0 -43
  238. package/node_modules/@contrast/sec-obs/node_modules/@contrast/dep-hooks/lib/package-finder.js +0 -79
  239. package/node_modules/@contrast/sec-obs/node_modules/@contrast/dep-hooks/package.json +0 -29
  240. package/node_modules/@contrast/sec-obs/node_modules/@contrast/logger/LICENSE +0 -12
  241. package/node_modules/@contrast/sec-obs/node_modules/@contrast/logger/README.md +0 -270
  242. package/node_modules/@contrast/sec-obs/node_modules/@contrast/logger/lib/index.d.ts +0 -16
  243. package/node_modules/@contrast/sec-obs/node_modules/@contrast/logger/lib/index.js +0 -132
  244. package/node_modules/@contrast/sec-obs/node_modules/@contrast/logger/lib/serializers.d.ts +0 -33
  245. package/node_modules/@contrast/sec-obs/node_modules/@contrast/logger/lib/serializers.js +0 -75
  246. package/node_modules/@contrast/sec-obs/node_modules/@contrast/logger/lib/utils.d.ts +0 -15
  247. package/node_modules/@contrast/sec-obs/node_modules/@contrast/logger/lib/utils.js +0 -34
  248. package/node_modules/@contrast/sec-obs/node_modules/@contrast/logger/package.json +0 -28
  249. package/node_modules/@contrast/sec-obs/node_modules/@contrast/patcher/LICENSE +0 -12
  250. package/node_modules/@contrast/sec-obs/node_modules/@contrast/patcher/README.md +0 -51
  251. package/node_modules/@contrast/sec-obs/node_modules/@contrast/patcher/lib/index.d.ts +0 -101
  252. package/node_modules/@contrast/sec-obs/node_modules/@contrast/patcher/lib/index.js +0 -544
  253. package/node_modules/@contrast/sec-obs/node_modules/@contrast/patcher/package.json +0 -25
  254. package/node_modules/@contrast/sec-obs/node_modules/@contrast/rewriter/LICENSE +0 -12
  255. package/node_modules/@contrast/sec-obs/node_modules/@contrast/rewriter/README.md +0 -6
  256. package/node_modules/@contrast/sec-obs/node_modules/@contrast/rewriter/lib/cache.js +0 -318
  257. package/node_modules/@contrast/sec-obs/node_modules/@contrast/rewriter/lib/index.js +0 -216
  258. package/node_modules/@contrast/sec-obs/node_modules/@contrast/rewriter/lib/rewrite-is-deadzoned.js +0 -143
  259. package/node_modules/@contrast/sec-obs/node_modules/@contrast/rewriter/package.json +0 -30
  260. package/node_modules/@contrast/sec-obs/node_modules/@contrast/scopes/LICENSE +0 -12
  261. package/node_modules/@contrast/sec-obs/node_modules/@contrast/scopes/lib/constants.js +0 -26
  262. package/node_modules/@contrast/sec-obs/node_modules/@contrast/scopes/lib/index.d.ts +0 -46
  263. package/node_modules/@contrast/sec-obs/node_modules/@contrast/scopes/lib/index.js +0 -70
  264. package/node_modules/@contrast/sec-obs/node_modules/@contrast/scopes/lib/install/bluebird.js +0 -128
  265. package/node_modules/@contrast/sec-obs/node_modules/@contrast/scopes/lib/install/index.js +0 -34
  266. package/node_modules/@contrast/sec-obs/node_modules/@contrast/scopes/lib/install/mongodb-core.js +0 -83
  267. package/node_modules/@contrast/sec-obs/node_modules/@contrast/scopes/lib/install/mongodb3.js +0 -89
  268. package/node_modules/@contrast/sec-obs/node_modules/@contrast/scopes/lib/install/mongodb4.js +0 -80
  269. package/node_modules/@contrast/sec-obs/node_modules/@contrast/scopes/lib/install/mongodb6.js +0 -46
  270. package/node_modules/@contrast/sec-obs/node_modules/@contrast/scopes/lib/install/mysql.js +0 -151
  271. package/node_modules/@contrast/sec-obs/node_modules/@contrast/scopes/lib/install/redis.js +0 -79
  272. package/node_modules/@contrast/sec-obs/node_modules/@contrast/scopes/lib/utils.js +0 -35
  273. package/node_modules/@contrast/sec-obs/node_modules/@contrast/scopes/package.json +0 -28
  274. package/node_modules/form-data/README.md.bak +0 -355
  275. package/node_modules/path-to-regexp/Readme.md +0 -216
  276. package/node_modules/path-to-regexp/dist/index.d.ts +0 -136
  277. package/node_modules/path-to-regexp/dist/index.js +0 -403
  278. package/node_modules/path-to-regexp/dist/index.js.map +0 -1
  279. package/node_modules/path-to-regexp/package.json +0 -62
@@ -1,143 +0,0 @@
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
- 'use strict';
16
-
17
- const { sep } = require('path');
18
-
19
- // todo: find optimal way to do these lookups
20
- const DEADZONED_PATHS = [
21
- 'ast-types', // CONTRAST-33909: `String` injection causes this module to crash.
22
- 'angular',
23
- 'acorn',
24
- 'archiver',
25
- 'archiver-utils',
26
- 'bcrypt',
27
- 'bcrypt-nodejs',
28
- 'bcryptjs', // node_modules/bcryptjs/index.js, node_modules/bcryptjs/dist/bcrypt.js
29
- '@babel', // this should handle all namespaced packages
30
- 'babel',
31
- 'babel-cli',
32
- 'babel-core',
33
- 'babel-traverse',
34
- 'babel-generator',
35
- 'babylon',
36
- 'bn.js',
37
- 'browserify',
38
- 'bson',
39
- 'bunyan',
40
- 'chai', // not sure why chai was rewritten
41
- 'coffeescript',
42
- 'compression',
43
- '@cyclonedx',
44
- 'etag',
45
- // 'cookie', // todo: verify this doesn't break sources/propagation (*)
46
- // 'cookie-signature', // (*)
47
- 'gzippo', // 149 weekly downloads
48
- // 'handlebars', // (*)
49
- 'handlebars-precompiler',
50
- // 'hbs', // ditto
51
- 'html-webpack-plugin',
52
- 'iconv-lite',
53
- 'jquery',
54
- 'jsrsasign',
55
- 'less',
56
- // 'dustjs-linkedin', // todo
57
- 'logger-console', // 2 weekly downloads
58
- 'loopback-datasource-juggler',
59
- 'moment',
60
- 'moment-timezone',
61
- 'node-forge',
62
- 'node-webpack',
63
- 'pem',
64
- 'react',
65
- 'react-dom', // doesn't this cover the next line?
66
- //'react-dom/server',
67
- 'requirejs',
68
- 'semver',
69
- 'strong-remoting',
70
- 'type-is',
71
- 'uglify-js',
72
- ];
73
-
74
- // maybe make the value an object for more complex strategies in the future
75
- // NOTE: they key should appear in the list above as well. if it's not there
76
- // then this object will never be checked.
77
- const CUSTOM_REWRITERS = {
78
- 'acorn': 'no-propagation',
79
- 'archiver': 'no-propagation',
80
- 'babel-core': 'no-propagation',
81
- '@babel': 'no-propagation',
82
- 'bcryptjs': 'no-propagation',
83
- 'bson': 'no-propagation',
84
- 'coffeescript': 'no-propagation',
85
- 'jsrsasign': 'no-propagation',
86
- 'less': 'no-propagation',
87
- '@cyclonedx': 'no-propagation',
88
- };
89
-
90
- const nodeModules = `${sep}node_modules${sep}`;
91
-
92
- function rewriteIsDeadzoned(absolutePath) {
93
- // we should only match the last node_modules folder
94
- const startingPoint = absolutePath.lastIndexOf(nodeModules) + nodeModules.length;
95
-
96
- for (const path of DEADZONED_PATHS) {
97
- const start = absolutePath.indexOf(path, startingPoint);
98
- // we return the name of the deadzoned module if it is found
99
- if (start >= 0 && (start + path.length === absolutePath.length || absolutePath[start + path.length] === sep)) {
100
- return path;
101
- }
102
- }
103
-
104
- return undefined;
105
- }
106
-
107
- // the next function is used if/when we implement custom rewrite strategies.
108
- // NODE-3512 implements that and this was taken from there.
109
-
110
- /**
111
- * Returns an array with a package name and that package's rewrite strategy.
112
- * The package name is only returned the package strategy is not 'default'.
113
- * Strategies:
114
- * - 'default': rewrite the module using the original, default rewriter
115
- * - 'deadzone': do not rewrite the module
116
- * - 'no-propagation': rewrite the module with the no-propagation rewriter
117
- *
118
- * why does this return the package name? mostly just because it had to extract
119
- * it from the path, so returning means the caller doesn't have to.
120
- *
121
- * @param {string} absolutePath
122
- * @returns {[string | undefined, 'default' | 'deadzone' | 'no-propagation']}
123
- */
124
- function getPackageRewriteStrategy(absolutePath) {
125
- const pkg = rewriteIsDeadzoned(absolutePath);
126
- if (!pkg) {
127
- return [undefined, 'default'];
128
- }
129
-
130
- const strategy = CUSTOM_REWRITERS[pkg];
131
- if (strategy && process.env.CSI_USE_CUSTOM_REWRITERS) {
132
- return [pkg, strategy];
133
- }
134
-
135
- return [pkg, 'deadzone'];
136
- }
137
-
138
- module.exports = {
139
- DEADZONED_PATHS,
140
- CUSTOM_REWRITERS,
141
- rewriteIsDeadzoned,
142
- getPackageRewriteStrategy,
143
- };
@@ -1,30 +0,0 @@
1
- {
2
- "name": "@contrast/rewriter",
3
- "version": "1.29.0",
4
- "description": "A transpilation tool mainly used for instrumentation",
5
- "license": "SEE LICENSE IN LICENSE",
6
- "author": "Contrast Security <nodejs@contrastsecurity.com> (https://www.contrastsecurity.com)",
7
- "files": [
8
- "lib/",
9
- "!*.test.*",
10
- "!tsconfig.*",
11
- "!*.map"
12
- ],
13
- "main": "lib/index.js",
14
- "types": "types/index.d.ts",
15
- "engines": {
16
- "npm": ">=6.13.7 <7 || >= 8.3.1",
17
- "node": ">= 16.9.1"
18
- },
19
- "scripts": {
20
- "test": "bash ../scripts/test.sh"
21
- },
22
- "dependencies": {
23
- "@contrast/agent-swc-plugin": "3.0.0",
24
- "@contrast/common": "1.33.0",
25
- "@contrast/config": "1.48.0",
26
- "@contrast/core": "1.53.0",
27
- "@contrast/logger": "1.26.0",
28
- "@swc/core": "1.11.24"
29
- }
30
- }
@@ -1,12 +0,0 @@
1
- Copyright: 2025 Contrast Security, Inc
2
- Contact: support@contrastsecurity.com
3
- License: Commercial
4
-
5
- NOTICE: This Software and the patented inventions embodied within may only be
6
- used as part of Contrast Security’s commercial offerings. Even though it is
7
- made available through public repositories, use of this Software is subject to
8
- the applicable End User Licensing Agreement found at
9
- https://www.contrastsecurity.com/enduser-terms-0317a or as otherwise agreed
10
- between Contrast Security and the End User. The Software may not be reverse
11
- engineered, modified, repackaged, sold, redistributed or otherwise used in a
12
- way not consistent with the End User License Agreement.
@@ -1,26 +0,0 @@
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 PATCH_TYPES = {
19
- // a patch related to retaining or applying async context
20
- ASYNC_CONTEXT: 'async context',
21
- FRAMEWORK: 'framework',
22
- };
23
-
24
- module.exports = {
25
- PATCH_TYPES
26
- };
@@ -1,46 +0,0 @@
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
- import { RequestStore } from '@contrast/common';
17
- import { AsyncLocalStorage } from 'async_hooks';
18
-
19
- export interface Sources extends AsyncLocalStorage<RequestStore> {}
20
-
21
- export interface InstrumentationStore {
22
- name: string;
23
- lock: boolean;
24
- }
25
-
26
- export interface Instrumentation
27
- extends AsyncLocalStorage<InstrumentationStore> {
28
- isLocked(): boolean;
29
- }
30
-
31
- export interface Scopes {
32
- sources: Sources;
33
- instrumentation: Instrumentation;
34
- wrap<TArgs extends any[], TReturnValue>(
35
- callback: (...args: TArgs) => TReturnValue
36
- ): (...args: TArgs) => TReturnValue;
37
- install(): Promise<void>;
38
- }
39
-
40
- interface Core {
41
- scopes: Scopes;
42
- }
43
-
44
- declare function init(core: Core): Scopes;
45
-
46
- export = init;
@@ -1,70 +0,0 @@
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 { AsyncLocalStorage } = require('async_hooks');
19
- const { Core } = require('@contrast/core/lib/ioc/core');
20
-
21
- module.exports = Core.makeComponent({
22
- name: 'scopes',
23
- factory(core) {
24
- core.scopes = {};
25
- const sources = new AsyncLocalStorage();
26
- const instrumentation = new AsyncLocalStorage();
27
- // If not enabled or no store then we are NOT locked - not opt-in
28
- instrumentation.isLocked = function() {
29
- return !!instrumentation.getStore()?.lock;
30
- };
31
-
32
- /**
33
- * Wraps a given callback to be run in the AsyncLocalStorages that were active during the wrapping
34
- * @param {function} cb the callback that is to be wrapped
35
- * @return {function} the callback wrapped in .run() methods from the active AsyncLocalStorages
36
- */
37
- function wrap(cb) {
38
- let fn = cb;
39
-
40
- for (const storage of [instrumentation, sources]) {
41
- const store = storage.getStore();
42
- if (store) {
43
- const _fn = fn;
44
- fn = function(...args) {
45
- return storage.run(store, _fn.bind(this), ...args);
46
- };
47
- }
48
- }
49
-
50
- if (fn !== cb) {
51
- Object.defineProperty(fn, 'name', { value: cb?.name, writable: false });
52
- }
53
-
54
- return fn;
55
- }
56
-
57
- const install = () => {
58
- require('./install')(core).install();
59
- };
60
-
61
- Object.assign(core.scopes, {
62
- sources,
63
- instrumentation,
64
- wrap,
65
- install
66
- });
67
-
68
- return core.scopes;
69
- }
70
- });
@@ -1,128 +0,0 @@
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 { ASYNC_CONTEXT } = require('../constants').PATCH_TYPES;
19
-
20
- /**
21
- * Exports a function handling the patching of `mysql` and `mysql2` packages
22
- * @param {Object} core the core Contrast object in v5
23
- * @param {Object} core.depHooks instance of @contrast/depHooks
24
- * @param {Object} core.patcher instance of @contrast/patcher
25
- * @param {Object} hooks the relevant hooks that are to be used in the patching, found in ./hooks.js
26
- * @param {function} patchConfigHook hook for setting the config option asyncHooks: true
27
- * @param {function} addCallbacksHook hook for .addCallbacks method
28
- */
29
- module.exports = ({ depHooks, patcher, logger, scopes: { wrap } }) => {
30
- function install() {
31
- depHooks.resolve({ name: 'bluebird', version: '<4' }, (bluebird) => {
32
- patchConfig(bluebird);
33
- patchAddCallbacks(bluebird);
34
- patchGetNewLibraryCopy(bluebird);
35
- });
36
- }
37
-
38
- /**
39
- * This forces bluebird to use async hooks.
40
- * This is to ensure our AsyncStorage will
41
- * properly bind bluebird Promises when running
42
- * in a Scope(request, propagator, no instrumentation)
43
- *
44
- * http://bluebirdjs.com/docs/api/promise.config.html#async-hooks
45
- */
46
- function patchConfig(bluebird) {
47
- if (typeof bluebird.config === 'function') {
48
- bluebird.config({ asyncHooks: true });
49
-
50
- patcher.patch(bluebird, 'config', {
51
- name: 'bluebird.config',
52
- patchType: ASYNC_CONTEXT,
53
- pre: patchConfigHook,
54
- });
55
- }
56
- }
57
-
58
- /**
59
- * Even with async_hooks option set we still need to bind callbacks to our CLS
60
- * namespace.
61
- */
62
- function patchAddCallbacks(bluebird) {
63
- if (bluebird.prototype && bluebird.prototype._addCallbacks) {
64
- patcher.patch(bluebird.prototype, '_addCallbacks', {
65
- name: 'bluebird.prototype._addCallbacks',
66
- patchType: ASYNC_CONTEXT,
67
- pre: addCallbacksHook(),
68
- });
69
- } else {
70
- logger.warn('skip patching bluebird.prototype._addCallbacks');
71
- }
72
- }
73
-
74
- /**
75
- * Ensures that new library copies are also instrumented.
76
- * @param {function} bluebird the library export
77
- */
78
- function patchGetNewLibraryCopy(bluebird) {
79
- if (typeof bluebird.getNewLibraryCopy !== 'function') {
80
- return;
81
- }
82
-
83
- patcher.patch(bluebird, 'getNewLibraryCopy', {
84
- name: 'bluebird.getNewLibraryCopy',
85
- patchType: ASYNC_CONTEXT,
86
- post(data) {
87
- patchAddCallbacks(data.result);
88
- },
89
- });
90
- }
91
-
92
- /**
93
- * Hook for setting the config options
94
- * @param {string} data the argument for the preHook
95
- */
96
- function patchConfigHook(data) {
97
- const opts = data.args[0];
98
- if (opts) {
99
- opts.asyncHooks = true;
100
- }
101
- }
102
-
103
- function addCallbacksHook() {
104
- /**
105
- * Binds callback to the relevant AsyncStorage.
106
- * @param {object} data the argument for the preHook
107
- * @param {object} data.args the arguments passed to `._addCallbacks` method
108
- */
109
- return function ({ args, funcKey, name }) {
110
- try {
111
- // bind every function argument
112
- for (let idx = 0; idx < args.length; idx++) {
113
- if (typeof args[idx] !== 'function') {
114
- continue;
115
- }
116
- // we bind the initial context of the function to be available inside ours
117
- args[idx] = wrap(args[idx]);
118
- }
119
- } catch (err) {
120
- logger.warn({ err, funcKey }, 'An error occurred in %s', name);
121
- }
122
- };
123
- }
124
-
125
- return {
126
- install
127
- };
128
- };
@@ -1,34 +0,0 @@
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
- module.exports = function (core) {
19
- /**
20
- * Setup known required patches
21
- */
22
- const asyncStorageHooks = {
23
- install() {
24
- require('./mysql')(core).install();
25
- require('./redis')(core).install();
26
- require('./mongodb-core')(core).install();
27
- require('./mongodb3')(core).install();
28
- require('./mongodb4')(core).install();
29
- require('./bluebird')(core).install();
30
- },
31
- };
32
-
33
- return asyncStorageHooks;
34
- };
@@ -1,83 +0,0 @@
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 { PATCH_TYPES: { ASYNC_CONTEXT } } = require('../constants');
19
- const { resolveCallbackIndex } = require('../utils');
20
-
21
- /**
22
- * Exports a function handling the patching of `mongodb-core` package
23
- * @param {Object} core the core Contrast object in v5
24
- */
25
- module.exports = function (core) {
26
- const { depHooks, patcher, logger, scopes: { wrap } } = core;
27
- const mongoDBCoreServer = { name: 'mongodb-core', version: '<4', file: 'lib/topologies/server.js' };
28
- const mongoDBCoreCursor = { name: 'mongodb-core', version: '<4', file: 'lib/cursor.js' };
29
-
30
- function install() {
31
- depHooks.resolve(
32
- mongoDBCoreServer,
33
- (server) => {
34
- const methods = ['command', 'insert', 'update', 'remove', 'logout'];
35
- methods.forEach((method) =>
36
- patcher.patch(server.prototype, method, {
37
- name: `mongodb-core.${server.prototype.constructor.name}.prototype.${method}`,
38
- patchType: ASYNC_CONTEXT,
39
- pre: methodHook(),
40
- })
41
- );
42
- }
43
- );
44
-
45
- depHooks.resolve(
46
- mongoDBCoreCursor,
47
- (cursor) => {
48
- const method = 'next';
49
- patcher.patch(cursor.prototype, method, {
50
- name: `mongodb-core.${cursor.prototype.constructor.name}.prototype.${method}`,
51
- patchType: ASYNC_CONTEXT,
52
- pre: methodHook(),
53
- });
54
- }
55
- );
56
- }
57
-
58
- /**
59
- * Returns a function/hook to be used with a given mongodb-core/mongodb method
60
- * @param {string} method the method for hooking
61
- * @param {object} hookedModule instance of mongoDBCoreServer
62
- * @return {function} a preHook for the given mongodb-core method
63
- */
64
- function methodHook() {
65
- /**
66
- * Binds callback (when present) to the relevant AsyncStorage.
67
- * @param {object} data the argument for the preHook
68
- * @param {object} data.args the arguments passed to hooked method
69
- */
70
- return function ({ args, funcKey, name }) {
71
- try {
72
- const indexOfCallback = resolveCallbackIndex(args);
73
- args[indexOfCallback] = wrap(args[indexOfCallback]);
74
- } catch (err) {
75
- logger.warn({ err, funcKey }, 'An error occurred in %s', name);
76
- }
77
- };
78
- }
79
-
80
- return {
81
- install
82
- };
83
- };
@@ -1,89 +0,0 @@
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 { PATCH_TYPES: { ASYNC_CONTEXT } } = require('../constants');
19
- const { resolveCallbackIndex } = require('../utils');
20
-
21
- /**
22
- * Exports a function handling the patching of `mongodb` package for v3.3.0 up to v4.0.0, excluding
23
- * @param {Object} core the core Contrast object in v5
24
- */
25
- module.exports = function (core) {
26
- const { depHooks, patcher, logger, scopes: { wrap } } = core;
27
- const mongoDBTopologyBase = { name: 'mongodb', file: 'lib/topologies/topology_base.js', version: '>=3.3.0 <4' };
28
- const mongoDBTNativeTopology = { name: 'mongodb', file: 'lib/topologies/native_topology.js', version: '>=3.3.0 <4' };
29
- const mongoDBCursor = { name: 'mongodb', file: 'lib/cursor.js', version: '>=3.3.0 <4' };
30
-
31
- function install() {
32
- depHooks.resolve(mongoDBTopologyBase, (tpl) => {
33
- const methods = ['command', 'insert', 'update', 'remove'];
34
- methods.forEach((method) => {
35
- patcher.patch(tpl.TopologyBase.prototype, method, {
36
- name: `mongodb.TopologyBase.prototype.${method}`,
37
- patchType: ASYNC_CONTEXT,
38
- pre: methodHook()
39
- });
40
- });
41
- });
42
-
43
- depHooks.resolve(mongoDBTNativeTopology, (tpl) => {
44
- const methods = ['command', 'insert', 'update', 'remove'];
45
- methods.forEach((method) => {
46
- patcher.patch(tpl.prototype, method, {
47
- name: `mongodb.NativeTopology.prototype.${method}`,
48
- patchType: ASYNC_CONTEXT,
49
- pre: methodHook()
50
- });
51
- });
52
- });
53
-
54
- depHooks.resolve(
55
- mongoDBCursor,
56
- (cursor) => {
57
- patcher.patch(cursor.prototype, '_next', {
58
- name: 'mongodb.Cursor.prototype._next',
59
- patchType: ASYNC_CONTEXT,
60
- pre: methodHook(),
61
- });
62
- });
63
- }
64
-
65
- /**
66
- * Returns a function/hook to be used with a given mongodb-core/mongodb method
67
- * @param {string} name the method for hooking
68
- * @return {function} a preHook for the given mongodb-core method
69
- */
70
- function methodHook() {
71
- /**
72
- * Binds callback (when present) to the relevant AsyncStorage.
73
- * @param {object} data the argument for the preHook
74
- * @param {object} data.args the arguments passed to hooked method
75
- */
76
- return function ({ args, funcKey, name }) {
77
- try {
78
- const indexOfCallback = resolveCallbackIndex(args);
79
- args[indexOfCallback] = wrap(args[indexOfCallback]);
80
- } catch (err) {
81
- logger.warn({ err, funcKey }, 'An error occurred in %s', name);
82
- }
83
- };
84
- }
85
-
86
- return {
87
- install
88
- };
89
- };