@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,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrast/route-coverage",
3
- "version": "1.45.1",
3
+ "version": "1.46.0",
4
4
  "description": "Handles route discovery and observation",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "author": "Contrast Security <nodejs@contrastsecurity.com> (https://www.contrastsecurity.com)",
@@ -20,14 +20,14 @@
20
20
  "test": "bash ../scripts/test.sh"
21
21
  },
22
22
  "dependencies": {
23
- "@contrast/common": "1.34.1",
24
- "@contrast/config": "1.49.1",
25
- "@contrast/dep-hooks": "1.23.1",
23
+ "@contrast/common": "1.35.0",
24
+ "@contrast/config": "1.50.0",
25
+ "@contrast/core": "1.55.0",
26
+ "@contrast/dep-hooks": "1.24.0",
26
27
  "@contrast/fn-inspect": "^4.3.0",
27
- "@contrast/logger": "1.27.1",
28
- "@contrast/patcher": "1.26.1",
29
- "@contrast/scopes": "1.24.1",
30
- "semver": "^7.6.0",
31
- "path-to-regexp": "^8.2.0"
28
+ "@contrast/logger": "1.28.0",
29
+ "@contrast/patcher": "1.27.0",
30
+ "@contrast/scopes": "1.25.0",
31
+ "semver": "^7.6.0"
32
32
  }
33
33
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrast/scopes",
3
- "version": "1.24.1",
3
+ "version": "1.25.0",
4
4
  "description": "Handles AsyncLocalStorage scopes",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "author": "Contrast Security <nodejs@contrastsecurity.com> (https://www.contrastsecurity.com)",
@@ -20,9 +20,9 @@
20
20
  "test": "bash ../scripts/test.sh"
21
21
  },
22
22
  "dependencies": {
23
- "@contrast/core": "1.54.1",
24
- "@contrast/dep-hooks": "1.23.1",
25
- "@contrast/logger": "1.27.1",
26
- "@contrast/patcher": "1.26.1"
23
+ "@contrast/core": "1.55.0",
24
+ "@contrast/dep-hooks": "1.24.0",
25
+ "@contrast/logger": "1.28.0",
26
+ "@contrast/patcher": "1.27.0"
27
27
  }
28
28
  }
@@ -16,7 +16,7 @@
16
16
  'use strict';
17
17
  const patchType = 'observability';
18
18
  const onFinished = require('on-finished');
19
- const { primordials: { StringPrototypeSplit } } = require('@contrast/common');
19
+ const { normalizeURI, primordials: { StringPrototypeSplit } } = require('@contrast/common');
20
20
 
21
21
  module.exports = function(core) {
22
22
  const {
@@ -48,7 +48,7 @@ module.exports = function(core) {
48
48
  if (!method || !url) return next();
49
49
 
50
50
  const [path] = StringPrototypeSplit.call(url, '?'); // TODO: NODE-3701 sync discovered route name and trace
51
- const name = `${method} ${path}`;
51
+ const name = `${method} ${normalizeURI(path)}`;
52
52
  const rootSpan = tracer.startSpan(name);
53
53
  // TODO: Audit other attributes and add as needed
54
54
  const headers = getHeaders(req);
@@ -69,6 +69,23 @@ describe('observability root spans', function () {
69
69
  expect(span.end).to.have.been.called;
70
70
  });
71
71
 
72
+ it('generates a span with the normalized uri', function() {
73
+ emit('request', {
74
+ method: 'GET',
75
+ url: '/path/b09112a0-a58f-487a-ab4b-3608bd64fb3f/fd4b78312634a236d11da0f9c32526e5b8261afa/42/end'
76
+ }, resMock);
77
+ expect(startSpan).to.have.been.calledWith('GET /path/{uuid}/{hash}/{n}/end');
78
+ const span = startSpan.getCall(0).returnValue;
79
+ expect(span.setAttributes).to.have.been.calledWith({
80
+ 'network.protocol.name': moduleName,
81
+ 'http.request.method': 'GET',
82
+ });
83
+ expect(span.setAttributes).to.have.been.calledWith({
84
+ 'http.response.status_code': 200
85
+ });
86
+ expect(span.end).to.have.been.called;
87
+ });
88
+
72
89
  it('generates a span with the attributes derived from headers', function() {
73
90
  const headersSymbol = Symbol('Headers');
74
91
  reqMock[headersSymbol] = {
@@ -16,7 +16,7 @@
16
16
  'use strict';
17
17
  const patchType = 'observability';
18
18
  const onFinished = require('on-finished');
19
- const { isString } = require('@contrast/common');
19
+ const { isString, normalizeURI } = require('@contrast/common');
20
20
 
21
21
  module.exports = function(core) {
22
22
  const {
@@ -37,7 +37,7 @@ module.exports = function(core) {
37
37
  protocol = protocol.endsWith(':') ? protocol : `${protocol}:`;
38
38
  path = path || pathname;
39
39
  port &&= `:${port}`;
40
- return `${protocol}//${hostname}${port}${path}`;
40
+ return `${protocol}//${hostname}${port}${normalizeURI(path)}`;
41
41
  }
42
42
 
43
43
  return core.secObs.traces.outboundServiceCall = {
@@ -138,4 +138,21 @@ describe('observability outbound-service-call action', function () {
138
138
  });
139
139
  expect(span.end).to.have.been.called;
140
140
  });
141
+
142
+ it('generates a span with normalized path', function() {
143
+ core.secObs.tracing.getContext.returns({});
144
+ core.secObs.tracing.runContext.returns({});
145
+ http.request({
146
+ protocol: 'http',
147
+ hostname: 'example.com',
148
+ path: '/path/b09112a0-a58f-487a-ab4b-3608bd64fb3f/fd4b78312634a236d11da0f9c32526e5b8261afa/42/end'
149
+ });
150
+ expect(startSpan).to.have.been.calledWith('outbound-service-call', undefined, {});
151
+ const span = startSpan.getCall(0).returnValue;
152
+ expect(span.setAttributes).to.have.been.calledWith({
153
+ 'url.full': 'http://example.com/path/{uuid}/{hash}/{n}/end',
154
+ 'server.address': 'example.com',
155
+ });
156
+ expect(span.end).to.have.been.called;
157
+ });
141
158
  });
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrast/sec-obs",
3
- "version": "1.0.0-alpha.8",
3
+ "version": "1.0.0-alpha.9",
4
4
  "description": "Contrast service providing framework-agnostic Observability support",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "author": "Contrast Security <nodejs@contrastsecurity.com> (https://www.contrastsecurity.com)",
@@ -17,14 +17,14 @@
17
17
  "test": "bash ../scripts/test.sh"
18
18
  },
19
19
  "dependencies": {
20
- "@contrast/common": "1.33.0",
21
- "@contrast/config": "1.48.0",
22
- "@contrast/core": "1.53.0",
23
- "@contrast/dep-hooks": "1.22.0",
24
- "@contrast/logger": "1.26.0",
25
- "@contrast/patcher": "1.25.0",
26
- "@contrast/rewriter": "1.29.0",
27
- "@contrast/scopes": "1.23.0",
20
+ "@contrast/common": "1.35.0",
21
+ "@contrast/config": "1.50.0",
22
+ "@contrast/core": "1.55.0",
23
+ "@contrast/dep-hooks": "1.24.0",
24
+ "@contrast/logger": "1.28.0",
25
+ "@contrast/patcher": "1.27.0",
26
+ "@contrast/rewriter": "1.31.0",
27
+ "@contrast/scopes": "1.25.0",
28
28
  "@opentelemetry/api": "^1.9.0",
29
29
  "@opentelemetry/exporter-metrics-otlp-http": "^0.57.1",
30
30
  "@opentelemetry/exporter-trace-otlp-http": "^0.57.1",
@@ -0,0 +1,109 @@
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 { EventEmitter } = require('events');
19
+ const onFinished = require('on-finished');
20
+ const { set, Event } = require('@contrast/common');
21
+ const { Core } = require('@contrast/core/lib/ioc/core');
22
+ const NormalizedUriMapper = require('./normalized-uri-mapper');
23
+ const { HttpSourceInfo } = require('./source-info');
24
+
25
+ const componentName = 'sources';
26
+
27
+ module.exports = Core.makeComponent({
28
+ name: componentName,
29
+ factory: (core) => new Sources(core),
30
+ });
31
+
32
+ class Sources {
33
+ constructor(core) {
34
+ // decorate
35
+ set(core, componentName, this);
36
+
37
+ this.core = core;
38
+ this._hooks = new EventEmitter();
39
+ this._normalizedUriMapper = new NormalizedUriMapper(core);
40
+ }
41
+
42
+ addHook(name, handler) {
43
+ // only this one hook atm
44
+ if (name === 'onSource') this._hooks.on(name, handler);
45
+ }
46
+
47
+ aroundHook(serverType) {
48
+ const { _hooks, _normalizedUriMapper, core } = this;
49
+
50
+ return function (next, data) {
51
+ const { args: [event, req, res] } = data;
52
+
53
+ if (event !== 'request') {
54
+ if (event === 'listening') {
55
+ // take a snapshot of Perf.all at this point. this will get logged
56
+ // at some point on the perf interval timer.
57
+ core.Perf.mark('listening');
58
+ core.messages.emit(Event.SERVER_LISTENING, { type: serverType, server: data.obj });
59
+ }
60
+ return next();
61
+ }
62
+
63
+ core.Perf.requestCount += 1;
64
+
65
+ const sourceInfo = new HttpSourceInfo({
66
+ serverType,
67
+ raw: req,
68
+ normalizedUriMapper: _normalizedUriMapper,
69
+ });
70
+ const store = { sourceInfo };
71
+
72
+ onFinished(res, (/* err, req */) => {
73
+ core.messages.emit(Event.RESPONSE_FINISH, store);
74
+ });
75
+
76
+ return core.scopes.sources.run(store, () => {
77
+ if (_hooks._events.onSource) {
78
+ _hooks.emit('onSource', {
79
+ // future: non-http sources will have their own type
80
+ sourceType: 'HTTP',
81
+ store,
82
+ incomingMessage: req,
83
+ serverResponse: res,
84
+ });
85
+ }
86
+
87
+ return next();
88
+ });
89
+ };
90
+ }
91
+
92
+ install() {
93
+ const { instrumentation, sources } = this.core;
94
+
95
+ ['http', 'https', 'spdy', 'http2'].forEach((moduleName) => {
96
+ instrumentation.instrument({
97
+ moduleName,
98
+ patchObjects: [{
99
+ name: 'Server.prototype',
100
+ methods: ['emit'],
101
+ patchType: 'sources',
102
+ around: sources.aroundHook(moduleName)
103
+ }]
104
+ });
105
+ });
106
+ }
107
+ }
108
+
109
+ module.exports.HttpSourceInfo = HttpSourceInfo;
@@ -0,0 +1,120 @@
1
+ 'use strict';
2
+
3
+ const EventEmitter = require('events');
4
+ const { expect } = require('chai');
5
+ const sinon = require('sinon');
6
+ const { initProtectFixture } = require('@contrast/test/fixtures');
7
+ const mocks = require('@contrast/test/mocks');
8
+ const proxyquire = require('proxyquire');
9
+
10
+ describe('agentify sources', function () {
11
+ [
12
+ {
13
+ name: 'http',
14
+ expected: {
15
+ port: 8080,
16
+ protocol: 'http',
17
+ serverType: 'http',
18
+ },
19
+ },
20
+ {
21
+ name: 'https',
22
+ expected: {
23
+ port: 8080,
24
+ protocol: 'https',
25
+ serverType: 'https',
26
+ },
27
+ },
28
+ {
29
+ name: 'spdy',
30
+ expected: {
31
+ port: 8080,
32
+ protocol: 'https',
33
+ serverType: 'spdy',
34
+ },
35
+ },
36
+ {
37
+ name: 'http2',
38
+ method: 'createServer',
39
+ expected: {
40
+ port: 8080,
41
+ protocol: 'https',
42
+ serverType: 'spdy',
43
+ },
44
+ },
45
+ {
46
+ name: 'http2',
47
+ method: 'createSecureServer',
48
+ expected: {
49
+ port: 8080,
50
+ protocol: 'https',
51
+ serverType: 'spdy',
52
+ },
53
+ }
54
+ ].forEach(({ name, method, expected }) => {
55
+ describe(`${name} sources using ${method || 'Server'}()`, function () {
56
+ let core, api, ServerMock, reqMock, resMock, onFinishedMock;
57
+
58
+ beforeEach(function () {
59
+ ({ core } = initProtectFixture());
60
+ ServerMock = function ServerMock() {
61
+ this.e = new EventEmitter();
62
+ };
63
+ ServerMock.prototype.emit = function (...args) {
64
+ this.e.emit(...args);
65
+ };
66
+ ServerMock.prototype.on = function (...args) {
67
+ this.e.on(...args);
68
+ };
69
+ api = {
70
+ Server: ServerMock,
71
+ createServer() {
72
+ return new ServerMock();
73
+ },
74
+ createSecureServer() {
75
+ return new ServerMock();
76
+ }
77
+ };
78
+ reqMock = mocks.incomingMessage();
79
+ // resMock = new EventEmitter();
80
+ onFinishedMock = sinon.stub();
81
+
82
+ core.depHooks.resolve.withArgs(sinon.match({ name: 'http' })).yields(api);
83
+ proxyquire('.', {
84
+ 'on-finished': onFinishedMock,
85
+ })(core).install();
86
+ });
87
+
88
+ it('"request" events run in scope with correct sourceInfo', function () {
89
+ const server = method ? api[method]() : new ServerMock();
90
+ let store;
91
+
92
+ server.on('request', function () {
93
+ store = core.scopes.sources.getStore();
94
+ });
95
+
96
+ server.emit('request', reqMock, resMock);
97
+
98
+ expect(store.sourceInfo).to.deep.include({
99
+ port: 8080,
100
+ protocol: 'http',
101
+ serverType: 'http',
102
+ });
103
+
104
+ expect(onFinishedMock).to.have.been.calledWith(resMock);
105
+ });
106
+
107
+ it('non-"request" events do not run in scope', function () {
108
+ const server = method ? api[method]() : new ServerMock();
109
+ let store;
110
+
111
+ server.on('foo', function () {
112
+ store = core.scopes.sources.getStore();
113
+ });
114
+
115
+ server.emit('foo', reqMock, resMock);
116
+ expect(store).to.be.undefined;
117
+ });
118
+ });
119
+ });
120
+ });
@@ -15,13 +15,14 @@
15
15
  'use strict';
16
16
 
17
17
  const {
18
+ Event,
18
19
  get,
19
20
  set,
20
21
  primordials: { StringPrototypeSubstr, StringPrototypeSplit }
21
22
  } = require('@contrast/common');
22
23
 
23
- class NormalizedUrlMapper {
24
- constructor() {
24
+ class NormalizedUriMapper {
25
+ constructor(core) {
25
26
  this._db = {
26
27
  // index by static routes e.g.
27
28
  // '/' => {}
@@ -39,6 +40,12 @@ class NormalizedUrlMapper {
39
40
  };
40
41
  this._defaultDynamicRe = /\(|\?|\||\[|\*|\+|\{/;
41
42
  this._hapiDynamicRe = /\(|\?|\||\[|\*|\+/;
43
+
44
+ core.messages.on(Event.ROUTE_COVERAGE_DISCOVERY_FINISHED, (routes) => {
45
+ for (const routeInfo of routes) {
46
+ this.handleDiscover(routeInfo);
47
+ }
48
+ });
42
49
  }
43
50
 
44
51
  _getPathSegments(uriPath) {
@@ -171,4 +178,4 @@ class NormalizedUrlMapper {
171
178
  }
172
179
  }
173
180
 
174
- module.exports = NormalizedUrlMapper;
181
+ module.exports = NormalizedUriMapper;
@@ -0,0 +1,59 @@
1
+ 'use strict';
2
+
3
+ const EventEmitter = require('node:events');
4
+ const { expect } = require('chai');
5
+ const { Event } = require('@contrast/common');
6
+ const frameworkRoutingData = require('@contrast/test/data/framework-routing-data');
7
+ const NormalizedUrlMapper = require('./normalized-uri-mapper');
8
+
9
+ describe('route-coverage NormalizedUrlMapper', function() {
10
+ const testData = Object.values(frameworkRoutingData()).flatMap((a) => a);
11
+ let mapper;
12
+ let messages;
13
+
14
+ this.beforeEach(function() {
15
+ messages = new EventEmitter();
16
+ mapper = new NormalizedUrlMapper({
17
+ messages,
18
+ });
19
+ });
20
+
21
+ describe('.map', function() {
22
+ it('returns null if no discovery events were handled', function() {
23
+ [
24
+ '/user/1',
25
+ '/user/2',
26
+ '/user/3',
27
+ '/user/4',
28
+ '/user/1/cart',
29
+ '/user/2/cart',
30
+ '/user/3/cart',
31
+ '/user/4/cart',
32
+ '/products/all',
33
+ '/products/all',
34
+ '/products/1',
35
+ '/products/2',
36
+ '/products/3',
37
+ '/products/4',
38
+ ].forEach((uriPath) => {
39
+ expect(mapper.map(uriPath)).to.be.null;
40
+ });
41
+ });
42
+
43
+ it('returns normalizedUrl mapped from generic uriPath', function() {
44
+ messages.emit(Event.ROUTE_COVERAGE_DISCOVERY_FINISHED, testData.map((d) => d.routeInfo));
45
+ testData.forEach((td) => {
46
+ const { routeInfo, paths, hasMapping } = td;
47
+
48
+ for (const uriPath of paths) {
49
+ // todo - dynamic and regex paths
50
+ if (hasMapping === false) {
51
+ expect(mapper.map(uriPath)).to.be.null;
52
+ } else {
53
+ expect(mapper.map(uriPath)).to.equal(routeInfo.normalizedUrl);
54
+ }
55
+ }
56
+ });
57
+ });
58
+ });
59
+ });
@@ -12,9 +12,3 @@
12
12
  * engineered, modified, repackaged, sold, redistributed or otherwise used in a
13
13
  * way not consistent with the End User License Agreement.
14
14
  */
15
-
16
- 'use strict';
17
-
18
- module.exports = {
19
- CONTRAST_REDACTED: 'contrast-redacted',
20
- };
@@ -0,0 +1,183 @@
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 {
19
+ primordials: {
20
+ RegExpPrototypeExec,
21
+ StringPrototypeReplace,
22
+ StringPrototypeSlice,
23
+ StringPrototypeSplit,
24
+ StringPrototypeToLowerCase,
25
+ }
26
+ } = require('@contrast/common');
27
+
28
+ const NormalizationPatterns = {
29
+ UUID: [/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i, '{uuid}'],
30
+ NUMERICAL: [/^\d+$/i, '{n}'],
31
+ HASH: [/([a-fA-F0-9]{2}){16,}/, '{hash}'],
32
+ // we can extend these as needed
33
+ };
34
+
35
+ class HttpSourceInfo {
36
+ /**
37
+ * @param {object} param
38
+ * @param {string} param.serverType
39
+ * @param {any} param.normalizedUriMapper
40
+ * @param {IncomingMessage} param.raw
41
+ */
42
+ constructor({
43
+ serverType,
44
+ normalizedUriMapper,
45
+ raw,
46
+ }) {
47
+ this._headerLookupCache = {};
48
+ this._normalizedUri = null;
49
+ this._normalizedUriMasked = null;
50
+ this._normalizedUriSegments = [];
51
+ this._normalizedUriMapper = normalizedUriMapper;
52
+ //
53
+ this.httpVersion = raw.httpVersion;
54
+ this.ip = raw.socket.remoteAddress ? StringPrototypeReplace.call(raw.socket.remoteAddress, /::ffff:/, '') : undefined;
55
+ this.port = raw.socket.address?.()?.port || 0;
56
+ this.protocol = serverType == 'http' ? 'http' : 'https'; // todo
57
+ this.serverType = serverType;
58
+ this.time = Date.now();
59
+ this.method = StringPrototypeToLowerCase.call(raw.method);
60
+ this.rawHeaders = [];
61
+
62
+ for (let i = 0; i < raw.rawHeaders.length; i += 2) {
63
+ const iNext = i + 1;
64
+ const headerName = StringPrototypeToLowerCase.call(raw.rawHeaders[i]);
65
+
66
+ headerName == 'content-type' && (this.contentType = raw.rawHeaders[iNext]);
67
+
68
+ this.rawHeaders[i] = headerName;
69
+ this.rawHeaders[iNext] = headerName == 'content-type' ?
70
+ StringPrototypeToLowerCase.call(raw.rawHeaders[iNext]) :
71
+ raw.rawHeaders[iNext];
72
+
73
+ if (
74
+ headerName == 'upgrade' &&
75
+ StringPrototypeToLowerCase.call(this.rawHeaders[iNext]) == 'websocket'
76
+ ) {
77
+ this.protocol = 'ws';
78
+ }
79
+ }
80
+
81
+ const idx = raw.url.indexOf('?');
82
+ if (idx >= 0) {
83
+ this.uriPath = StringPrototypeSlice.call(raw.url, 0, idx);
84
+ this.queries = StringPrototypeSlice.call(raw.url, idx + 1);
85
+ } else {
86
+ this.uriPath = raw.url;
87
+ this.queries = '';
88
+ }
89
+ }
90
+
91
+ /**
92
+ * Looks through rawHeaders to find it. Caches results to avoid subsequent lookups.
93
+ * @param {string} name needs to be lowercase
94
+ * @returns {string}
95
+ */
96
+ getHeader(name) {
97
+ if (name in this._headerLookupCache) return this._headerLookupCache[name];
98
+
99
+ for (let i = 0; i < this.rawHeaders.length; i += 2) {
100
+ if (name == this.rawHeaders[i]) {
101
+ return (this._headerLookupCache[name] = this.rawHeaders[i + 1]);
102
+ }
103
+ }
104
+
105
+ return null;
106
+ }
107
+
108
+ /**
109
+ * The normalizedUri is a computed field
110
+ */
111
+ get normalizedUri() {
112
+ const r = Reflect.get(this, '_normalizedUri');
113
+ if (!r) this.generateNormalizedUri();
114
+ return Reflect.get(this, '_normalizedUri');
115
+ }
116
+
117
+ set normalizedUri(value) {
118
+ Reflect.set(this, '_normalizedUri', value);
119
+ }
120
+
121
+ generateNormalizedUri() {
122
+ let normalizedUri;
123
+
124
+ // leverage route discovery data to try to find route template
125
+ normalizedUri = this._normalizedUriMapper?.map?.(this.uriPath);
126
+
127
+ if (normalizedUri) {
128
+ // if we can map to the template we can use it for masked value too
129
+ this._normalizedUri = normalizedUri;
130
+ this._normalizedUriMasked = normalizedUri;
131
+ } else {
132
+ // if we can't find the template then test against common
133
+ // regular expressions to normalize/mask each segment per spec
134
+ const arr = StringPrototypeSplit.call(this.uriPath, '/');
135
+ let maskedUri = '';
136
+
137
+ normalizedUri = '';
138
+
139
+ for (let idx = 1; idx < arr.length; idx++) {
140
+ let normalSeg = arr[idx];
141
+ let maskedSeg = normalSeg;
142
+
143
+ let isPattern;
144
+
145
+ for (const [rx, substitution] of Object.values(NormalizationPatterns)) {
146
+ isPattern = !!RegExpPrototypeExec.call(rx, normalSeg);
147
+ if (isPattern) {
148
+ normalSeg = maskedSeg = substitution;
149
+ break;
150
+ }
151
+ }
152
+
153
+ if (!isPattern) {
154
+ if (idx > 1) {
155
+ maskedSeg = `${StringPrototypeSlice.call(normalSeg, 0, 2)}xxxx`;
156
+ } else {
157
+ // no masking/normalizing for first seg (called "context" in spec)
158
+ maskedSeg = arr[idx];
159
+ }
160
+ }
161
+
162
+ maskedUri += `/${maskedSeg}`;
163
+ normalizedUri += `/${normalSeg}`;
164
+ }
165
+
166
+ this._normalizedUri = normalizedUri;
167
+ this._normalizedUriMasked = maskedUri;
168
+ }
169
+ }
170
+
171
+ get normalizedUriMasked() {
172
+ const r = Reflect.get(this, '_normalizedUriMasked');
173
+ if (!r) this.generateNormalizedUri();
174
+ return Reflect.get(this, '_normalizedUriMasked');
175
+ }
176
+
177
+ set normalizedUriMasked(value) {
178
+ Reflect.set(this, '_normalizedUriMasked', value);
179
+ }
180
+ }
181
+
182
+ module.exports.HttpSourceInfo = HttpSourceInfo;
183
+ module.exports.NORMALIZE_PATTERNS = NormalizationPatterns;