@contrast/agent-bundle 5.40.0 → 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.
- package/node_modules/@contrast/agent/package.json +11 -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.js +1 -1
- 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/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/@types/node/README.md +2 -2
- package/node_modules/@types/node/fs.d.ts +13 -1
- package/node_modules/@types/node/http.d.ts +4 -19
- package/node_modules/@types/node/inspector.d.ts +53 -0
- package/node_modules/@types/node/package.json +2 -82
- 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/package.json +2 -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/form-data/README.md.bak +0 -355
|
@@ -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
|
+
});
|
|
@@ -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;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { expect } = require('chai');
|
|
4
|
+
const mocks = require('@contrast/test/mocks');
|
|
5
|
+
|
|
6
|
+
const { HttpSourceInfo } = require('./source-info');
|
|
7
|
+
|
|
8
|
+
describe('sources SourceInfo', function () {
|
|
9
|
+
[
|
|
10
|
+
{
|
|
11
|
+
uriPath: '/index',
|
|
12
|
+
expectedNormalized: '/index',
|
|
13
|
+
expectedNormalizedMasked: '/index',
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
uriPath: '/orders/abc-123',
|
|
17
|
+
expectedNormalized: '/orders/abc-123',
|
|
18
|
+
expectedNormalizedMasked: '/orders/abxxxx',
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
uriPath: '/orders/abc-123/item/123',
|
|
22
|
+
expectedNormalized: '/orders/abc-123/item/{n}',
|
|
23
|
+
expectedNormalizedMasked: '/orders/abxxxx/itxxxx/{n}',
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
uriPath: '/orders/1234',
|
|
27
|
+
expectedNormalized: '/orders/{n}',
|
|
28
|
+
expectedNormalizedMasked: '/orders/{n}',
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
uriPath: '/orders/93a0862a-09be-4292-bc6a-50d38dded69c',
|
|
32
|
+
expectedNormalized: '/orders/{uuid}',
|
|
33
|
+
expectedNormalizedMasked: '/orders/{uuid}',
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
uriPath: '/orders/0f1e2d3c4b5a6f7e8d9c0b1a2f3e4d5c',
|
|
37
|
+
expectedNormalized: '/orders/{hash}',
|
|
38
|
+
expectedNormalizedMasked: '/orders/{hash}',
|
|
39
|
+
},
|
|
40
|
+
].forEach(({
|
|
41
|
+
uriPath,
|
|
42
|
+
expectedNormalized,
|
|
43
|
+
expectedNormalizedMasked,
|
|
44
|
+
}) => {
|
|
45
|
+
it(`normalizedUri and normalizedUriMasked are built correctly: ${uriPath}`, function () {
|
|
46
|
+
const req = mocks.incomingMessage();
|
|
47
|
+
req.url = `${uriPath}?${req.queries}`;
|
|
48
|
+
|
|
49
|
+
const info = new HttpSourceInfo({
|
|
50
|
+
serverType: 'http',
|
|
51
|
+
raw: req
|
|
52
|
+
});
|
|
53
|
+
expect(info.normalizedUri).to.equal(expectedNormalized);
|
|
54
|
+
expect(info.normalizedUriMasked).to.equal(expectedNormalizedMasked);
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it('trims IPv6 prefixes from mapped IPv4 addresses', function () {
|
|
59
|
+
const req = mocks.incomingMessage();
|
|
60
|
+
req.socket.remoteAddress = '::ffff:127.0.0.1';
|
|
61
|
+
|
|
62
|
+
const info = new HttpSourceInfo({
|
|
63
|
+
serverType: 'http',
|
|
64
|
+
raw: req
|
|
65
|
+
});
|
|
66
|
+
expect(info.ip).to.equal('127.0.0.1');
|
|
67
|
+
});
|
|
68
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@contrast/sources",
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"description": "Instruments to have incoming messages run in async-local request scope.",
|
|
5
|
+
"main": "lib/index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
|
+
},
|
|
9
|
+
"author": "",
|
|
10
|
+
"license": "ISC",
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"@contrast/common": "1.35.0",
|
|
13
|
+
"@contrast/core": "1.55.0",
|
|
14
|
+
"on-finished": "^2.4.1"
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contrast/telemetry",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.30.0",
|
|
4
4
|
"description": "Telemetry reporting for the Contrast Node.js agent.",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"author": "Contrast Security <nodejs@contrastsecurity.com> (https://www.contrastsecurity.com)",
|
|
@@ -19,11 +19,11 @@
|
|
|
19
19
|
"test": "bash ../scripts/test.sh"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@contrast/common": "1.
|
|
23
|
-
"@contrast/config": "1.
|
|
24
|
-
"@contrast/core": "1.
|
|
25
|
-
"@contrast/logger": "1.
|
|
26
|
-
"axios": "^1.
|
|
22
|
+
"@contrast/common": "1.35.0",
|
|
23
|
+
"@contrast/config": "1.50.0",
|
|
24
|
+
"@contrast/core": "1.55.0",
|
|
25
|
+
"@contrast/logger": "1.28.0",
|
|
26
|
+
"axios": "^1.11.0",
|
|
27
27
|
"getmac": "^6.3.0"
|
|
28
28
|
}
|
|
29
29
|
}
|