@contrast/agent-bundle 5.40.0 → 5.42.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.
- package/node_modules/@contrast/agent/package.json +12 -11
- package/node_modules/@contrast/agent-swc-plugin/index.js +9 -3
- package/node_modules/@contrast/agent-swc-plugin/methods.js +15 -1
- package/node_modules/@contrast/agent-swc-plugin/package.json +5 -8
- package/node_modules/@contrast/agent-swc-plugin/rewriter.wasm +0 -0
- package/node_modules/@contrast/agentify/lib/index.js +2 -2
- package/node_modules/@contrast/agentify/package.json +15 -14
- package/node_modules/@contrast/architecture-components/package.json +5 -5
- package/node_modules/@contrast/assess/lib/dataflow/propagation/install/util-format.js +44 -21
- package/node_modules/@contrast/assess/lib/dataflow/sources/install/body-parser.js +1 -1
- package/node_modules/@contrast/assess/lib/dataflow/sources/install/koa/koa-bodyparsers.js +3 -1
- package/node_modules/@contrast/assess/lib/dataflow/sources/install/qs6.js +5 -5
- package/node_modules/@contrast/assess/lib/dataflow/sources/install/querystring.js +2 -1
- package/node_modules/@contrast/assess/lib/index.d.ts +0 -1
- package/node_modules/@contrast/assess/lib/make-source-context.js +7 -37
- package/node_modules/@contrast/assess/lib/sampler/common.js +7 -11
- package/node_modules/@contrast/assess/package.json +12 -11
- package/node_modules/@contrast/common/lib/types.d.ts +7 -1
- package/node_modules/@contrast/common/package.json +1 -1
- package/node_modules/@contrast/config/lib/common.js +1 -1
- package/node_modules/@contrast/config/lib/config.js +49 -27
- package/node_modules/@contrast/config/lib/index.d.ts +2 -2
- package/node_modules/@contrast/config/lib/options.js +4 -4
- package/node_modules/@contrast/config/package.json +4 -3
- package/node_modules/@contrast/core/lib/sensitive-data-masking/protect-listener.js +15 -15
- package/node_modules/@contrast/core/package.json +6 -6
- package/node_modules/@contrast/deadzones/package.json +5 -5
- package/node_modules/@contrast/dep-hooks/package.json +3 -3
- package/node_modules/@contrast/esm-hooks/package.json +6 -6
- package/node_modules/@contrast/instrumentation/lib/index.js +0 -1
- package/node_modules/@contrast/instrumentation/package.json +5 -5
- package/node_modules/@contrast/library-analysis/lib/install/library-reporting/dep.json +298 -148
- package/node_modules/@contrast/library-analysis/package.json +4 -4
- package/node_modules/@contrast/logger/lib/serializers.js +2 -2
- package/node_modules/@contrast/logger/package.json +3 -3
- package/node_modules/@contrast/metrics/package.json +6 -6
- package/node_modules/@contrast/patcher/package.json +2 -2
- package/node_modules/@contrast/protect/lib/get-source-context.js +3 -1
- package/node_modules/@contrast/protect/lib/index.js +6 -1
- package/node_modules/@contrast/protect/lib/input-analysis/handlers.js +7 -9
- package/node_modules/@contrast/protect/lib/input-analysis/install/http.js +18 -19
- package/node_modules/@contrast/protect/lib/input-analysis/install/qs6.js +18 -17
- package/node_modules/@contrast/protect/lib/input-analysis/install/universal-cookie4.js +2 -3
- package/node_modules/@contrast/protect/lib/make-source-context.js +22 -66
- package/node_modules/@contrast/protect/lib/semantic-analysis/handlers.js +73 -72
- package/node_modules/@contrast/protect/package.json +11 -11
- package/node_modules/@contrast/reporter/lib/reporters/contrast-ui/endpoints/application-activity/index.js +7 -7
- package/node_modules/@contrast/reporter/lib/reporters/contrast-ui/endpoints/application-activity/translations.d.ts +3 -3
- package/node_modules/@contrast/reporter/lib/reporters/contrast-ui/endpoints/application-activity/translations.js +24 -21
- package/node_modules/@contrast/reporter/lib/reporters/contrast-ui/endpoints/traces/index.d.ts +11 -11
- package/node_modules/@contrast/reporter/lib/reporters/contrast-ui/endpoints/traces/index.js +76 -86
- package/node_modules/@contrast/reporter/lib/reporters/contrast-ui/endpoints/traces/translations.d.ts +1 -2
- package/node_modules/@contrast/reporter/lib/reporters/contrast-ui/endpoints/traces/translations.js +8 -2
- package/node_modules/@contrast/reporter/lib/reporters/security-logger/index.d.ts +2 -2
- package/node_modules/@contrast/reporter/lib/reporters/security-logger/index.js +22 -20
- package/node_modules/@contrast/reporter/package.json +7 -7
- package/node_modules/@contrast/rewriter/lib/index.js +2 -2
- package/node_modules/@contrast/rewriter/package.json +6 -6
- package/node_modules/@contrast/route-coverage/lib/index.js +1 -9
- package/node_modules/@contrast/route-coverage/lib/install/express/express5.js +17 -19
- package/node_modules/@contrast/route-coverage/lib/install/hapi.js +9 -2
- package/node_modules/@contrast/route-coverage/package.json +8 -8
- package/node_modules/@contrast/scopes/package.json +5 -5
- package/node_modules/@contrast/sec-obs/lib/traces/http.js +2 -2
- package/node_modules/@contrast/sec-obs/lib/traces/http.test.js +17 -0
- package/node_modules/@contrast/sec-obs/lib/traces/outbound-service-call.js +2 -2
- package/node_modules/@contrast/sec-obs/lib/traces/outbound-service-call.test.js +17 -0
- package/node_modules/@contrast/sec-obs/package.json +9 -9
- package/node_modules/@contrast/sources/lib/index.js +109 -0
- package/node_modules/@contrast/sources/lib/index.test.js +120 -0
- package/node_modules/@contrast/{route-coverage/lib/normalized-url-mapper.js → sources/lib/normalized-uri-mapper.js} +10 -3
- package/node_modules/@contrast/sources/lib/normalized-uri-mapper.test.js +59 -0
- package/node_modules/@contrast/{sec-obs/node_modules/@contrast/core/lib/sensitive-data-masking/constants.js → sources/lib/req-data.js} +0 -6
- package/node_modules/@contrast/sources/lib/source-info.js +183 -0
- package/node_modules/@contrast/sources/lib/source-info.test.js +68 -0
- package/node_modules/@contrast/sources/package.json +16 -0
- package/node_modules/@contrast/telemetry/package.json +6 -6
- package/node_modules/@opentelemetry/semantic-conventions/build/esm/experimental_attributes.d.ts +2831 -77
- package/node_modules/@opentelemetry/semantic-conventions/build/esm/experimental_attributes.js +2831 -77
- package/node_modules/@opentelemetry/semantic-conventions/build/esm/experimental_attributes.js.map +1 -1
- package/node_modules/@opentelemetry/semantic-conventions/build/esm/experimental_metrics.d.ts +415 -98
- package/node_modules/@opentelemetry/semantic-conventions/build/esm/experimental_metrics.js +415 -98
- package/node_modules/@opentelemetry/semantic-conventions/build/esm/experimental_metrics.js.map +1 -1
- package/node_modules/@opentelemetry/semantic-conventions/build/esm/stable_attributes.d.ts +106 -0
- package/node_modules/@opentelemetry/semantic-conventions/build/esm/stable_attributes.js +106 -0
- package/node_modules/@opentelemetry/semantic-conventions/build/esm/stable_attributes.js.map +1 -1
- package/node_modules/@opentelemetry/semantic-conventions/build/esm/version.d.ts +1 -1
- package/node_modules/@opentelemetry/semantic-conventions/build/esm/version.js +1 -1
- package/node_modules/@opentelemetry/semantic-conventions/build/esm/version.js.map +1 -1
- package/node_modules/@opentelemetry/semantic-conventions/build/esnext/experimental_attributes.d.ts +2831 -77
- package/node_modules/@opentelemetry/semantic-conventions/build/esnext/experimental_attributes.js +2831 -77
- package/node_modules/@opentelemetry/semantic-conventions/build/esnext/experimental_attributes.js.map +1 -1
- package/node_modules/@opentelemetry/semantic-conventions/build/esnext/experimental_metrics.d.ts +415 -98
- package/node_modules/@opentelemetry/semantic-conventions/build/esnext/experimental_metrics.js +415 -98
- package/node_modules/@opentelemetry/semantic-conventions/build/esnext/experimental_metrics.js.map +1 -1
- package/node_modules/@opentelemetry/semantic-conventions/build/esnext/stable_attributes.d.ts +106 -0
- package/node_modules/@opentelemetry/semantic-conventions/build/esnext/stable_attributes.js +106 -0
- package/node_modules/@opentelemetry/semantic-conventions/build/esnext/stable_attributes.js.map +1 -1
- package/node_modules/@opentelemetry/semantic-conventions/build/esnext/version.d.ts +1 -1
- package/node_modules/@opentelemetry/semantic-conventions/build/esnext/version.js +1 -1
- package/node_modules/@opentelemetry/semantic-conventions/build/esnext/version.js.map +1 -1
- package/node_modules/@opentelemetry/semantic-conventions/build/src/experimental_attributes.d.ts +2831 -77
- package/node_modules/@opentelemetry/semantic-conventions/build/src/experimental_attributes.js +2858 -103
- package/node_modules/@opentelemetry/semantic-conventions/build/src/experimental_attributes.js.map +1 -1
- package/node_modules/@opentelemetry/semantic-conventions/build/src/experimental_metrics.d.ts +415 -98
- package/node_modules/@opentelemetry/semantic-conventions/build/src/experimental_metrics.js +420 -102
- package/node_modules/@opentelemetry/semantic-conventions/build/src/experimental_metrics.js.map +1 -1
- package/node_modules/@opentelemetry/semantic-conventions/build/src/stable_attributes.d.ts +106 -0
- package/node_modules/@opentelemetry/semantic-conventions/build/src/stable_attributes.js +106 -0
- package/node_modules/@opentelemetry/semantic-conventions/build/src/stable_attributes.js.map +1 -1
- package/node_modules/@opentelemetry/semantic-conventions/build/src/version.d.ts +1 -1
- package/node_modules/@opentelemetry/semantic-conventions/build/src/version.js +1 -1
- package/node_modules/@opentelemetry/semantic-conventions/build/src/version.js.map +1 -1
- package/node_modules/@opentelemetry/semantic-conventions/package.json +3 -3
- package/node_modules/@swc/types/index.d.ts +3 -2
- package/node_modules/@swc/types/package.json +1 -1
- package/node_modules/@types/node/README.md +2 -2
- package/node_modules/@types/node/crypto.d.ts +17 -1
- package/node_modules/@types/node/fs/promises.d.ts +7 -3
- package/node_modules/@types/node/fs.d.ts +11 -1
- package/node_modules/@types/node/http.d.ts +4 -19
- package/node_modules/@types/node/http2.d.ts +13 -11
- package/node_modules/@types/node/inspector.d.ts +163 -6
- package/node_modules/@types/node/module.d.ts +24 -0
- package/node_modules/@types/node/package.json +4 -89
- package/node_modules/@types/node/perf_hooks.d.ts +14 -0
- package/node_modules/@types/node/repl.d.ts +11 -1
- package/node_modules/@types/node/sqlite.d.ts +0 -1
- package/node_modules/@types/node/stream/web.d.ts +4 -0
- package/node_modules/@types/node/stream.d.ts +17 -6
- package/node_modules/@types/node/test.d.ts +16 -1
- package/node_modules/@types/node/timers.d.ts +0 -2
- package/node_modules/@types/node/url.d.ts +1 -1
- package/node_modules/@types/node/util.d.ts +6 -2
- package/node_modules/@types/node/worker_threads.d.ts +12 -0
- package/node_modules/@types/node/zlib.d.ts +8 -2
- package/node_modules/axios/CHANGELOG.md +17 -0
- package/node_modules/axios/README.md +1 -4
- package/node_modules/axios/dist/axios.js +39 -5
- package/node_modules/axios/dist/axios.js.map +1 -1
- package/node_modules/axios/dist/axios.min.js +2 -2
- package/node_modules/axios/dist/axios.min.js.map +1 -1
- package/node_modules/axios/dist/browser/axios.cjs +46 -9
- package/node_modules/axios/dist/browser/axios.cjs.map +1 -1
- package/node_modules/axios/dist/esm/axios.js +46 -9
- package/node_modules/axios/dist/esm/axios.js.map +1 -1
- package/node_modules/axios/dist/esm/axios.min.js +2 -2
- package/node_modules/axios/dist/esm/axios.min.js.map +1 -1
- package/node_modules/axios/dist/node/axios.cjs +46 -9
- package/node_modules/axios/dist/node/axios.cjs.map +1 -1
- package/node_modules/axios/index.d.cts +13 -2
- package/node_modules/axios/lib/core/Axios.js +2 -2
- package/node_modules/axios/lib/core/mergeConfig.js +1 -1
- package/node_modules/axios/lib/env/data.js +1 -1
- package/node_modules/axios/lib/helpers/throttle.js +1 -1
- package/node_modules/axios/lib/helpers/toURLEncodedForm.js +4 -3
- package/node_modules/axios/lib/utils.js +36 -0
- package/node_modules/axios/package.json +5 -5
- package/node_modules/deepmerge/.editorconfig +7 -0
- package/node_modules/deepmerge/.eslintcache +1 -0
- package/node_modules/deepmerge/changelog.md +167 -0
- package/node_modules/deepmerge/dist/cjs.js +133 -0
- package/node_modules/deepmerge/dist/umd.js +139 -0
- package/node_modules/deepmerge/index.d.ts +20 -0
- package/node_modules/deepmerge/index.js +106 -0
- package/node_modules/deepmerge/license.txt +21 -0
- package/node_modules/deepmerge/package.json +42 -0
- package/node_modules/deepmerge/readme.md +264 -0
- package/node_modules/deepmerge/rollup.config.js +22 -0
- package/node_modules/follow-redirects/package.json +1 -1
- package/node_modules/form-data/CHANGELOG.md +601 -0
- package/node_modules/form-data/{Readme.md → README.md} +4 -4
- package/node_modules/form-data/lib/form_data.js +2 -6
- package/node_modules/form-data/package.json +22 -6
- package/node_modules/nan/.github/workflows/ci.yml +8 -10
- package/node_modules/nan/.pre-commit-config.yaml +8 -0
- package/node_modules/nan/CHANGELOG.md +5 -1
- package/node_modules/nan/README.md +4 -4
- package/node_modules/nan/nan.h +16 -12
- package/node_modules/nan/nan_callbacks.h +13 -0
- package/node_modules/nan/nan_callbacks_12_inl.h +16 -2
- package/node_modules/nan/nan_callbacks_pre_12_inl.h +6 -2
- package/node_modules/nan/nan_maybe_43_inl.h +1 -1
- package/node_modules/nan/nan_maybe_pre_43_inl.h +1 -1
- package/node_modules/nan/nan_scriptorigin.h +11 -9
- package/node_modules/nan/nan_typedarray_contents.h +1 -1
- package/node_modules/nan/package.json +2 -2
- package/node_modules/undici-types/agent.d.ts +4 -0
- package/node_modules/undici-types/client-stats.d.ts +15 -0
- package/node_modules/undici-types/client.d.ts +6 -3
- package/node_modules/undici-types/mock-agent.d.ts +3 -0
- package/node_modules/undici-types/package.json +1 -1
- package/node_modules/undici-types/pool.d.ts +2 -0
- package/node_modules/undici-types/proxy-agent.d.ts +1 -0
- package/node_modules/yaml/README.md +2 -20
- package/node_modules/yaml/browser/dist/stringify/stringifyString.js +1 -1
- package/node_modules/yaml/dist/stringify/stringifyString.js +1 -1
- package/node_modules/yaml/package.json +2 -1
- package/package.json +3 -2
- package/node_modules/@contrast/agentify/lib/sources.js +0 -95
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/common/LICENSE +0 -12
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/common/lib/constants.d.ts +0 -385
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/common/lib/constants.js +0 -270
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/common/lib/index.d.ts +0 -40
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/common/lib/index.js +0 -228
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/common/lib/primordials.d.ts +0 -65
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/common/lib/primordials.js +0 -66
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/common/lib/types.d.ts +0 -383
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/common/lib/types.js +0 -30
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/common/package.json +0 -23
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/config/LICENSE +0 -12
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/config/README.md +0 -44
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/config/lib/common.js +0 -131
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/config/lib/config.js +0 -290
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/config/lib/index.d.ts +0 -328
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/config/lib/index.js +0 -29
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/config/lib/options.js +0 -836
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/config/lib/validators.js +0 -23
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/config/package.json +0 -27
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/core/LICENSE +0 -12
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/core/README.md +0 -98
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/core/lib/agent-info.js +0 -36
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/core/lib/app-info.js +0 -233
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/core/lib/build-id.js +0 -51
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/core/lib/capture-stacktrace.js +0 -256
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/core/lib/contrast-methods.js +0 -155
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/core/lib/index.d.ts +0 -52
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/core/lib/ioc/core.js +0 -95
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/core/lib/is-agent-path.js +0 -37
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/core/lib/messages.js +0 -28
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/core/lib/sensitive-data-masking/index.js +0 -63
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/core/lib/sensitive-data-masking/protect-listener.js +0 -111
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/core/lib/sensitive-data-masking/server-settings-listener.js +0 -44
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/core/lib/system-info/cloud-provider-metadata.js +0 -146
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/core/lib/system-info/index.js +0 -225
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/core/lib/system-info/linux-os-info.js +0 -137
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/core/lib/system-info/utils.js +0 -35
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/core/package.json +0 -33
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/dep-hooks/LICENSE +0 -12
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/dep-hooks/README.md +0 -94
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/dep-hooks/lib/export-handler-registry.d.ts +0 -121
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/dep-hooks/lib/export-handler-registry.js +0 -206
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/dep-hooks/lib/export-hook-descriptor.d.ts +0 -72
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/dep-hooks/lib/export-hook-descriptor.js +0 -88
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/dep-hooks/lib/handler-invoker.d.ts +0 -46
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/dep-hooks/lib/handler-invoker.js +0 -106
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/dep-hooks/lib/helpers.d.ts +0 -28
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/dep-hooks/lib/helpers.js +0 -66
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/dep-hooks/lib/index.d.ts +0 -115
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/dep-hooks/lib/index.js +0 -208
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/dep-hooks/lib/package-finder.d.ts +0 -43
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/dep-hooks/lib/package-finder.js +0 -79
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/dep-hooks/package.json +0 -29
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/logger/LICENSE +0 -12
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/logger/README.md +0 -270
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/logger/lib/index.d.ts +0 -16
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/logger/lib/index.js +0 -132
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/logger/lib/serializers.d.ts +0 -33
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/logger/lib/serializers.js +0 -75
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/logger/lib/utils.d.ts +0 -15
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/logger/lib/utils.js +0 -34
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/logger/package.json +0 -28
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/patcher/LICENSE +0 -12
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/patcher/README.md +0 -51
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/patcher/lib/index.d.ts +0 -101
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/patcher/lib/index.js +0 -544
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/patcher/package.json +0 -25
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/rewriter/LICENSE +0 -12
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/rewriter/README.md +0 -6
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/rewriter/lib/cache.js +0 -318
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/rewriter/lib/index.js +0 -216
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/rewriter/lib/rewrite-is-deadzoned.js +0 -143
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/rewriter/package.json +0 -30
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/scopes/LICENSE +0 -12
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/scopes/lib/constants.js +0 -26
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/scopes/lib/index.d.ts +0 -46
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/scopes/lib/index.js +0 -70
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/scopes/lib/install/bluebird.js +0 -128
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/scopes/lib/install/index.js +0 -34
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/scopes/lib/install/mongodb-core.js +0 -83
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/scopes/lib/install/mongodb3.js +0 -89
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/scopes/lib/install/mongodb4.js +0 -80
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/scopes/lib/install/mongodb6.js +0 -46
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/scopes/lib/install/mysql.js +0 -151
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/scopes/lib/install/redis.js +0 -79
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/scopes/lib/utils.js +0 -35
- package/node_modules/@contrast/sec-obs/node_modules/@contrast/scopes/package.json +0 -28
- package/node_modules/@types/node/ts5.1/compatibility/disposable.d.ts +0 -12
- package/node_modules/@types/node/ts5.1/index.d.ts +0 -98
- package/node_modules/form-data/README.md.bak +0 -355
|
@@ -16,7 +16,6 @@
|
|
|
16
16
|
'use strict';
|
|
17
17
|
|
|
18
18
|
const { callChildComponentMethodsSync, Event } = require('@contrast/common');
|
|
19
|
-
const NormalizedUrlMapper = require('./normalized-url-mapper');
|
|
20
19
|
|
|
21
20
|
/**
|
|
22
21
|
* @param {import('.').Core & {
|
|
@@ -36,21 +35,14 @@ module.exports = function init(core) {
|
|
|
36
35
|
const routeQueue = new Map();
|
|
37
36
|
|
|
38
37
|
const routeIdentifier = (method, signature) => `${method}.${signature}`;
|
|
39
|
-
const routeCoverage = core.routeCoverage = {
|
|
40
|
-
_normalizedUrlMapper: new NormalizedUrlMapper(),
|
|
41
|
-
|
|
42
|
-
uriPathToNormalizedUrl(uriPath) {
|
|
43
|
-
return this._normalizedUrlMapper.map(uriPath);
|
|
44
|
-
},
|
|
45
38
|
|
|
39
|
+
const routeCoverage = core.routeCoverage = {
|
|
46
40
|
discover(info) {
|
|
47
41
|
const id = routeIdentifier(info.method, info.signature);
|
|
48
42
|
if (routeInfo.get(id)) return;
|
|
49
43
|
|
|
50
44
|
logger.trace({ info }, 'Discovered new route:');
|
|
51
45
|
routeInfo.set(id, info);
|
|
52
|
-
this._normalizedUrlMapper.handleDiscover(info);
|
|
53
|
-
|
|
54
46
|
},
|
|
55
47
|
|
|
56
48
|
discoveryFinished() {
|
|
@@ -386,10 +386,14 @@ class ExpressInstrumentation {
|
|
|
386
386
|
// `value` is a terminal Layer with observable signatures.
|
|
387
387
|
// emit discovery after appending metadata.
|
|
388
388
|
if (value[kMetaKey]) {
|
|
389
|
-
|
|
390
|
-
|
|
389
|
+
const observables = this.generateObservables(metas, value.handle);
|
|
390
|
+
if (observables) {
|
|
391
|
+
if (!value[kMetaKey].observables) {
|
|
392
|
+
value[kMetaKey].observables = observables;
|
|
393
|
+
} else {
|
|
394
|
+
Object.assign(value[kMetaKey].observables, observables);
|
|
395
|
+
}
|
|
391
396
|
}
|
|
392
|
-
Object.assign(value[kMetaKey].observables, this.generateObservables(metas, value.handle));
|
|
393
397
|
self.discover(value[kMetaKey]);
|
|
394
398
|
}
|
|
395
399
|
}
|
|
@@ -411,31 +415,28 @@ class ExpressInstrumentation {
|
|
|
411
415
|
maybeLayer?.constructor?.name == 'Layer' &&
|
|
412
416
|
!maybeLayer?.stack?.length
|
|
413
417
|
) {
|
|
414
|
-
//
|
|
415
418
|
let _data = data.get(maybeLayer);
|
|
419
|
+
|
|
416
420
|
if (!_data) {
|
|
417
|
-
_data = {
|
|
421
|
+
_data = { paths: [] };
|
|
418
422
|
data.set(maybeLayer, _data);
|
|
419
423
|
}
|
|
420
424
|
|
|
421
425
|
// you can mount a router on itself
|
|
422
426
|
// prevent infinitely recursing into self-mounted routers
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
if (isNested) {
|
|
432
|
-
// todo: we don't support recursive router discovery/observation case atm
|
|
433
|
-
// stop to avoid infinite traversal
|
|
427
|
+
for (const visitedPath of _data.paths) {
|
|
428
|
+
// these conditions indicate recursive nesting at particular path
|
|
429
|
+
if (
|
|
430
|
+
path.length > visitedPath.length &&
|
|
431
|
+
visitedPath.every((el, i) => path[i] == el)
|
|
432
|
+
) {
|
|
434
433
|
path.pop();
|
|
435
434
|
continue loopKeys;
|
|
436
435
|
}
|
|
437
436
|
}
|
|
438
437
|
|
|
438
|
+
_data.paths.push([...path]); // copy because path argument mutates
|
|
439
|
+
|
|
439
440
|
const halt = cb(path, key, maybeLayer, target) === false;
|
|
440
441
|
if (halt) return;
|
|
441
442
|
}
|
|
@@ -500,9 +501,6 @@ class ExpressInstrumentation {
|
|
|
500
501
|
// build signature lookup based on each template (normalizeUri)
|
|
501
502
|
const map = templates.reduce((acc, routeTemplate) => {
|
|
502
503
|
if (!routeTemplate) routeTemplate = '/';
|
|
503
|
-
if (routeTemplate?.includes?.('typecheck')) {
|
|
504
|
-
// console.dir({ info, template });
|
|
505
|
-
}
|
|
506
504
|
acc[routeTemplate] = `${type}.${method}('${routeTemplate}', ${formattedHandler})`;
|
|
507
505
|
return acc;
|
|
508
506
|
}, {});
|
|
@@ -62,11 +62,18 @@ module.exports = function init(core) {
|
|
|
62
62
|
patcher.patch(data.result.route.settings, 'handler', {
|
|
63
63
|
name: 'route.settings.handler',
|
|
64
64
|
patchType,
|
|
65
|
-
|
|
65
|
+
// this needs to be in a pre-hook so that the route
|
|
66
|
+
// data is in the store before our dataflow hooks run
|
|
67
|
+
pre({ args }) {
|
|
66
68
|
const [{ method, path: url, route }] = args;
|
|
67
69
|
//TODO: Will this signature always be associated with an existing route?
|
|
68
70
|
const signature = createSignature(method, path);
|
|
69
|
-
routeCoverage.observe({
|
|
71
|
+
routeCoverage.observe({
|
|
72
|
+
signature,
|
|
73
|
+
url,
|
|
74
|
+
method: StringPrototypeToLowerCase.call(method),
|
|
75
|
+
normalizedUrl: route.path,
|
|
76
|
+
});
|
|
70
77
|
}
|
|
71
78
|
});
|
|
72
79
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contrast/route-coverage",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.47.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.
|
|
24
|
-
"@contrast/config": "1.
|
|
25
|
-
"@contrast/core": "1.
|
|
26
|
-
"@contrast/dep-hooks": "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",
|
|
27
27
|
"@contrast/fn-inspect": "^4.3.0",
|
|
28
|
-
"@contrast/logger": "1.
|
|
29
|
-
"@contrast/patcher": "1.
|
|
30
|
-
"@contrast/scopes": "1.
|
|
28
|
+
"@contrast/logger": "1.28.0",
|
|
29
|
+
"@contrast/patcher": "1.27.0",
|
|
30
|
+
"@contrast/scopes": "1.25.0",
|
|
31
31
|
"semver": "^7.6.0"
|
|
32
32
|
}
|
|
33
33
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contrast/scopes",
|
|
3
|
-
"version": "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.
|
|
24
|
-
"@contrast/dep-hooks": "1.
|
|
25
|
-
"@contrast/logger": "1.
|
|
26
|
-
"@contrast/patcher": "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.
|
|
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.
|
|
21
|
-
"@contrast/config": "1.
|
|
22
|
-
"@contrast/core": "1.
|
|
23
|
-
"@contrast/dep-hooks": "1.
|
|
24
|
-
"@contrast/logger": "1.
|
|
25
|
-
"@contrast/patcher": "1.
|
|
26
|
-
"@contrast/rewriter": "1.
|
|
27
|
-
"@contrast/scopes": "1.
|
|
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
|
|
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 =
|
|
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
|
+
});
|