dd-trace 6.0.0-pre-ca25754 → 6.0.0-pre-3f6ad7e
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/README.md +8 -1
- package/index.d.ts +21 -6
- package/init.js +27 -3
- package/package.json +6 -6
- package/packages/datadog-esbuild/index.js +9 -33
- package/packages/datadog-instrumentations/src/check_require_cache.js +41 -0
- package/packages/datadog-instrumentations/src/helpers/hooks.js +1 -1
- package/packages/datadog-instrumentations/src/helpers/register.js +7 -1
- package/packages/datadog-instrumentations/src/jest.js +1 -49
- package/packages/datadog-instrumentations/src/lodash.js +31 -0
- package/packages/datadog-instrumentations/src/playwright.js +6 -1
- package/packages/datadog-instrumentations/src/utils/src/extract-package-and-module-path.js +33 -0
- package/packages/dd-trace/src/appsec/iast/analyzers/hardcoded-base-analyzer.js +1 -0
- package/packages/dd-trace/src/appsec/iast/analyzers/hardcoded-password-analyzer.js +4 -0
- package/packages/dd-trace/src/appsec/iast/iast-log.js +2 -33
- package/packages/dd-trace/src/appsec/iast/taint-tracking/csi-methods.js +3 -0
- package/packages/dd-trace/src/appsec/iast/taint-tracking/operations.js +10 -1
- package/packages/dd-trace/src/appsec/iast/taint-tracking/taint-tracking-impl.js +55 -1
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-analyzers/hardcoded-password-analyzer.js +13 -0
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-handler.js +8 -2
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/index.js +6 -6
- package/packages/dd-trace/src/config.js +25 -8
- package/packages/dd-trace/src/encode/0.4.js +50 -3
- package/packages/dd-trace/src/plugins/database.js +20 -5
- package/packages/dd-trace/src/plugins/index.js +0 -1
- package/packages/dd-trace/src/profiling/profiler.js +23 -7
- package/packages/dd-trace/src/proxy.js +7 -1
- package/packages/dd-trace/src/serverless.js +3 -5
- package/packages/dd-trace/src/telemetry/index.js +9 -3
- package/packages/dd-trace/src/telemetry/logs/log-collector.js +42 -1
package/README.md
CHANGED
|
@@ -108,4 +108,11 @@ If you would like to trace your bundled application then please read this page o
|
|
|
108
108
|
|
|
109
109
|
## Security Vulnerabilities
|
|
110
110
|
|
|
111
|
-
Please refer to the [SECURITY.md](https://github.com/DataDog/dd-trace-js/blob/master/SECURITY.md) document if you have found a security issue.
|
|
111
|
+
Please refer to the [SECURITY.md](https://github.com/DataDog/dd-trace-js/blob/master/SECURITY.md) document if you have found a security issue.
|
|
112
|
+
|
|
113
|
+
## Datadog With OpenTelemetery
|
|
114
|
+
|
|
115
|
+
Please refer to the [Node.js Custom Instrumentation using OpenTelemetry API](https://docs.datadoghq.com/tracing/trace_collection/custom_instrumentation/nodejs/otel/) document. It includes information on how to use the OpenTelemetry API with dd-trace-js
|
|
116
|
+
|
|
117
|
+
Note that our internal implementation of the OpenTelemetry API is currently set within the version range `>=1.0.0 <1.9.0`. This range will be updated at a regular cadence therefore, we recommend updating your tracer to the latest release to ensure up to date support.
|
|
118
|
+
|
package/index.d.ts
CHANGED
|
@@ -144,6 +144,7 @@ interface Plugins {
|
|
|
144
144
|
"aws-sdk": tracer.plugins.aws_sdk;
|
|
145
145
|
"bunyan": tracer.plugins.bunyan;
|
|
146
146
|
"cassandra-driver": tracer.plugins.cassandra_driver;
|
|
147
|
+
"child_process": tracer.plugins.child_process;
|
|
147
148
|
"connect": tracer.plugins.connect;
|
|
148
149
|
"couchbase": tracer.plugins.couchbase;
|
|
149
150
|
"cucumber": tracer.plugins.cucumber;
|
|
@@ -940,11 +941,15 @@ declare namespace tracer {
|
|
|
940
941
|
/** @hidden */
|
|
941
942
|
interface Http extends Instrumentation {
|
|
942
943
|
/**
|
|
943
|
-
* List of URLs that should be instrumented.
|
|
944
|
+
* List of URLs/paths that should be instrumented.
|
|
945
|
+
*
|
|
946
|
+
* Note that when used for an http client the entry represents a full
|
|
947
|
+
* outbound URL (`https://example.org/api/foo`) but when used as a
|
|
948
|
+
* server the entry represents an inbound path (`/api/foo`).
|
|
944
949
|
*
|
|
945
950
|
* @default /^.*$/
|
|
946
951
|
*/
|
|
947
|
-
allowlist?: string | RegExp | ((
|
|
952
|
+
allowlist?: string | RegExp | ((urlOrPath: string) => boolean) | (string | RegExp | ((urlOrPath: string) => boolean))[];
|
|
948
953
|
|
|
949
954
|
/**
|
|
950
955
|
* Deprecated in favor of `allowlist`.
|
|
@@ -952,15 +957,19 @@ declare namespace tracer {
|
|
|
952
957
|
* @deprecated
|
|
953
958
|
* @hidden
|
|
954
959
|
*/
|
|
955
|
-
whitelist?: string | RegExp | ((
|
|
960
|
+
whitelist?: string | RegExp | ((urlOrPath: string) => boolean) | (string | RegExp | ((urlOrPath: string) => boolean))[];
|
|
956
961
|
|
|
957
962
|
/**
|
|
958
|
-
* List of URLs that should not be instrumented. Takes precedence over
|
|
963
|
+
* List of URLs/paths that should not be instrumented. Takes precedence over
|
|
959
964
|
* allowlist if a URL matches an entry in both.
|
|
960
965
|
*
|
|
966
|
+
* Note that when used for an http client the entry represents a full
|
|
967
|
+
* outbound URL (`https://example.org/api/foo`) but when used as a
|
|
968
|
+
* server the entry represents an inbound path (`/api/foo`).
|
|
969
|
+
*
|
|
961
970
|
* @default []
|
|
962
971
|
*/
|
|
963
|
-
blocklist?: string | RegExp | ((
|
|
972
|
+
blocklist?: string | RegExp | ((urlOrPath: string) => boolean) | (string | RegExp | ((urlOrPath: string) => boolean))[];
|
|
964
973
|
|
|
965
974
|
/**
|
|
966
975
|
* Deprecated in favor of `blocklist`.
|
|
@@ -968,7 +977,7 @@ declare namespace tracer {
|
|
|
968
977
|
* @deprecated
|
|
969
978
|
* @hidden
|
|
970
979
|
*/
|
|
971
|
-
blacklist?: string | RegExp | ((
|
|
980
|
+
blacklist?: string | RegExp | ((urlOrPath: string) => boolean) | (string | RegExp | ((urlOrPath: string) => boolean))[];
|
|
972
981
|
|
|
973
982
|
/**
|
|
974
983
|
* An array of headers to include in the span metadata.
|
|
@@ -1199,6 +1208,12 @@ declare namespace tracer {
|
|
|
1199
1208
|
*/
|
|
1200
1209
|
interface cassandra_driver extends Instrumentation {}
|
|
1201
1210
|
|
|
1211
|
+
/**
|
|
1212
|
+
* This plugin automatically instruments the
|
|
1213
|
+
* [child_process](https://nodejs.org/api/child_process.html) module.
|
|
1214
|
+
*/
|
|
1215
|
+
interface child_process extends Instrumentation {}
|
|
1216
|
+
|
|
1202
1217
|
/**
|
|
1203
1218
|
* This plugin automatically instruments the
|
|
1204
1219
|
* [connect](https://github.com/senchalabs/connect) module.
|
package/init.js
CHANGED
|
@@ -1,7 +1,31 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const path = require('path')
|
|
4
|
+
const Module = require('module')
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
let initBailout = false
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
if (process.env.DD_INJECTION_ENABLED) {
|
|
9
|
+
// If we're running via single-step install, and we're not in the app's
|
|
10
|
+
// node_modules, then we should not initialize the tracer. This prevents
|
|
11
|
+
// single-step-installed tracer from clobbering the manually-installed tracer.
|
|
12
|
+
let resolvedInApp
|
|
13
|
+
const entrypoint = process.argv[1]
|
|
14
|
+
try {
|
|
15
|
+
resolvedInApp = Module.createRequire(entrypoint).resolve('dd-trace')
|
|
16
|
+
} catch (e) {
|
|
17
|
+
// Ignore. If we can't resolve the module, we assume it's not in the app.
|
|
18
|
+
}
|
|
19
|
+
if (resolvedInApp) {
|
|
20
|
+
const ourselves = path.join(__dirname, 'index.js')
|
|
21
|
+
if (ourselves !== resolvedInApp) {
|
|
22
|
+
initBailout = true
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (!initBailout) {
|
|
28
|
+
const tracer = require('.')
|
|
29
|
+
tracer.init()
|
|
30
|
+
module.exports = tracer
|
|
31
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dd-trace",
|
|
3
|
-
"version": "6.0.0-pre-
|
|
3
|
+
"version": "6.0.0-pre-3f6ad7e",
|
|
4
4
|
"description": "Datadog APM tracing client for JavaScript",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"typings": "index.d.ts",
|
|
@@ -71,17 +71,17 @@
|
|
|
71
71
|
},
|
|
72
72
|
"dependencies": {
|
|
73
73
|
"@datadog/native-appsec": "7.1.1",
|
|
74
|
-
"@datadog/native-iast-rewriter": "2.3.
|
|
75
|
-
"@datadog/native-iast-taint-tracking": "1.
|
|
74
|
+
"@datadog/native-iast-rewriter": "2.3.1",
|
|
75
|
+
"@datadog/native-iast-taint-tracking": "2.1.0",
|
|
76
76
|
"@datadog/native-metrics": "^2.0.0",
|
|
77
|
-
"@datadog/pprof": "5.
|
|
77
|
+
"@datadog/pprof": "5.3.0",
|
|
78
78
|
"@datadog/sketches-js": "^2.1.0",
|
|
79
|
-
"@opentelemetry/api": "
|
|
79
|
+
"@opentelemetry/api": ">=1.0.0 <1.9.0",
|
|
80
80
|
"@opentelemetry/core": "^1.14.0",
|
|
81
81
|
"crypto-randomuuid": "^1.0.0",
|
|
82
82
|
"dc-polyfill": "^0.1.4",
|
|
83
83
|
"ignore": "^5.2.4",
|
|
84
|
-
"import-in-the-middle": "^1.7.
|
|
84
|
+
"import-in-the-middle": "^1.7.4",
|
|
85
85
|
"int64-buffer": "^0.1.9",
|
|
86
86
|
"ipaddr.js": "^2.1.0",
|
|
87
87
|
"istanbul-lib-coverage": "3.2.0",
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
const instrumentations = require('../datadog-instrumentations/src/helpers/instrumentations.js')
|
|
6
6
|
const hooks = require('../datadog-instrumentations/src/helpers/hooks.js')
|
|
7
|
+
const extractPackageAndModulePath = require('../datadog-instrumentations/src/utils/src/extract-package-and-module-path')
|
|
7
8
|
|
|
8
9
|
for (const hook of Object.values(hooks)) {
|
|
9
10
|
hook()
|
|
@@ -21,7 +22,6 @@ for (const instrumentation of Object.values(instrumentations)) {
|
|
|
21
22
|
}
|
|
22
23
|
}
|
|
23
24
|
|
|
24
|
-
const NM = 'node_modules/'
|
|
25
25
|
const INSTRUMENTED = Object.keys(instrumentations)
|
|
26
26
|
const RAW_BUILTINS = require('module').builtinModules
|
|
27
27
|
const CHANNEL = 'dd-trace:bundler:load'
|
|
@@ -75,7 +75,10 @@ module.exports.setup = function (build) {
|
|
|
75
75
|
try {
|
|
76
76
|
fullPathToModule = dotFriendlyResolve(args.path, args.resolveDir)
|
|
77
77
|
} catch (err) {
|
|
78
|
-
|
|
78
|
+
if (DEBUG) {
|
|
79
|
+
console.warn(`Warning: Unable to find "${args.path}".` +
|
|
80
|
+
"Unless it's dead code this could cause a problem at runtime.")
|
|
81
|
+
}
|
|
79
82
|
return
|
|
80
83
|
}
|
|
81
84
|
const extracted = extractPackageAndModulePath(fullPathToModule)
|
|
@@ -93,7 +96,10 @@ module.exports.setup = function (build) {
|
|
|
93
96
|
} catch (err) {
|
|
94
97
|
if (err.code === 'MODULE_NOT_FOUND') {
|
|
95
98
|
if (!internal) {
|
|
96
|
-
|
|
99
|
+
if (DEBUG) {
|
|
100
|
+
console.warn(`Warning: Unable to find "${extracted.pkg}/package.json".` +
|
|
101
|
+
"Unless it's dead code this could cause a problem at runtime.")
|
|
102
|
+
}
|
|
97
103
|
}
|
|
98
104
|
return
|
|
99
105
|
} else {
|
|
@@ -175,33 +181,3 @@ function dotFriendlyResolve (path, directory) {
|
|
|
175
181
|
|
|
176
182
|
return require.resolve(path, { paths: [directory] })
|
|
177
183
|
}
|
|
178
|
-
|
|
179
|
-
/**
|
|
180
|
-
* For a given full path to a module,
|
|
181
|
-
* return the package name it belongs to and the local path to the module
|
|
182
|
-
* input: '/foo/node_modules/@co/stuff/foo/bar/baz.js'
|
|
183
|
-
* output: { pkg: '@co/stuff', path: 'foo/bar/baz.js' }
|
|
184
|
-
*/
|
|
185
|
-
function extractPackageAndModulePath (fullPath) {
|
|
186
|
-
const nm = fullPath.lastIndexOf(NM)
|
|
187
|
-
if (nm < 0) {
|
|
188
|
-
return { pkg: null, path: null }
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
const subPath = fullPath.substring(nm + NM.length)
|
|
192
|
-
const firstSlash = subPath.indexOf('/')
|
|
193
|
-
|
|
194
|
-
if (subPath[0] === '@') {
|
|
195
|
-
const secondSlash = subPath.substring(firstSlash + 1).indexOf('/')
|
|
196
|
-
|
|
197
|
-
return {
|
|
198
|
-
pkg: subPath.substring(0, firstSlash + 1 + secondSlash),
|
|
199
|
-
path: subPath.substring(firstSlash + 1 + secondSlash + 1)
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
return {
|
|
204
|
-
pkg: subPath.substring(0, firstSlash),
|
|
205
|
-
path: subPath.substring(firstSlash + 1)
|
|
206
|
-
}
|
|
207
|
-
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
/* eslint-disable no-console */
|
|
4
|
+
|
|
5
|
+
const extractPackageAndModulePath = require('./utils/src/extract-package-and-module-path')
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The lowest hanging fruit to debug an app that isn't tracing
|
|
9
|
+
* properly is to check that it is loaded before any modules
|
|
10
|
+
* that need to be instrumented. This function checks the
|
|
11
|
+
* `require.cache` to see if any supported packages have
|
|
12
|
+
* already been required and prints a warning.
|
|
13
|
+
*
|
|
14
|
+
* Note that this only going to work for modules within npm
|
|
15
|
+
* packages, like `express`, and not internal modules, like
|
|
16
|
+
* `http`.
|
|
17
|
+
*
|
|
18
|
+
* The output isn't necessarily 100% perfect. For example if the
|
|
19
|
+
* app loads a package we instrument but outside of an
|
|
20
|
+
* unsupported version then a warning would still be displayed.
|
|
21
|
+
* This is OK as the tracer should be loaded earlier anyway.
|
|
22
|
+
*/
|
|
23
|
+
module.exports = function () {
|
|
24
|
+
const packages = require('../../datadog-instrumentations/src/helpers/hooks')
|
|
25
|
+
const naughties = new Set()
|
|
26
|
+
let didWarn = false
|
|
27
|
+
|
|
28
|
+
for (const pathToModule of Object.keys(require.cache)) {
|
|
29
|
+
const { pkg } = extractPackageAndModulePath(pathToModule)
|
|
30
|
+
|
|
31
|
+
if (naughties.has(pkg)) continue
|
|
32
|
+
if (!(pkg in packages)) continue
|
|
33
|
+
|
|
34
|
+
console.error(`Warning: Package '${pkg}' was loaded before dd-trace! This may break instrumentation.`)
|
|
35
|
+
|
|
36
|
+
naughties.add(pkg)
|
|
37
|
+
didWarn = true
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (didWarn) console.error('Warning: Please ensure dd-trace is loaded before other modules.')
|
|
41
|
+
}
|
|
@@ -57,7 +57,6 @@ module.exports = {
|
|
|
57
57
|
'jest-config': () => require('../jest'),
|
|
58
58
|
'jest-environment-node': () => require('../jest'),
|
|
59
59
|
'jest-environment-jsdom': () => require('../jest'),
|
|
60
|
-
'jest-jasmine2': () => require('../jest'),
|
|
61
60
|
'jest-runtime': () => require('../jest'),
|
|
62
61
|
'jest-worker': () => require('../jest'),
|
|
63
62
|
knex: () => require('../knex'),
|
|
@@ -66,6 +65,7 @@ module.exports = {
|
|
|
66
65
|
kafkajs: () => require('../kafkajs'),
|
|
67
66
|
ldapjs: () => require('../ldapjs'),
|
|
68
67
|
'limitd-client': () => require('../limitd-client'),
|
|
68
|
+
lodash: () => require('../lodash'),
|
|
69
69
|
mariadb: () => require('../mariadb'),
|
|
70
70
|
memcached: () => require('../memcached'),
|
|
71
71
|
'microgateway-core': () => require('../microgateway-core'),
|
|
@@ -6,8 +6,12 @@ const semver = require('semver')
|
|
|
6
6
|
const Hook = require('./hook')
|
|
7
7
|
const requirePackageJson = require('../../../dd-trace/src/require-package-json')
|
|
8
8
|
const log = require('../../../dd-trace/src/log')
|
|
9
|
+
const checkRequireCache = require('../check_require_cache')
|
|
9
10
|
|
|
10
|
-
const {
|
|
11
|
+
const {
|
|
12
|
+
DD_TRACE_DISABLED_INSTRUMENTATIONS = '',
|
|
13
|
+
DD_TRACE_DEBUG = ''
|
|
14
|
+
} = process.env
|
|
11
15
|
|
|
12
16
|
const hooks = require('./hooks')
|
|
13
17
|
const instrumentations = require('./instrumentations')
|
|
@@ -27,6 +31,8 @@ if (!disabledInstrumentations.has('fetch')) {
|
|
|
27
31
|
const HOOK_SYMBOL = Symbol('hookExportsMap')
|
|
28
32
|
// TODO: make this more efficient
|
|
29
33
|
|
|
34
|
+
if (DD_TRACE_DEBUG && DD_TRACE_DEBUG.toLowerCase() !== 'false') checkRequireCache()
|
|
35
|
+
|
|
30
36
|
for (const packageName of names) {
|
|
31
37
|
if (disabledInstrumentations.has(packageName)) continue
|
|
32
38
|
|
|
@@ -19,7 +19,6 @@ const {
|
|
|
19
19
|
getJestTestName,
|
|
20
20
|
getJestSuitesToRun
|
|
21
21
|
} = require('../../datadog-plugin-jest/src/util')
|
|
22
|
-
const { DD_MAJOR } = require('../../../version')
|
|
23
22
|
|
|
24
23
|
const testSessionStartCh = channel('ci:jest:session:start')
|
|
25
24
|
const testSessionFinishCh = channel('ci:jest:session:finish')
|
|
@@ -68,14 +67,6 @@ let hasFilteredSkippableSuites = false
|
|
|
68
67
|
|
|
69
68
|
const sessionAsyncResource = new AsyncResource('bound-anonymous-fn')
|
|
70
69
|
|
|
71
|
-
const specStatusToTestStatus = {
|
|
72
|
-
pending: 'skip',
|
|
73
|
-
disabled: 'skip',
|
|
74
|
-
todo: 'skip',
|
|
75
|
-
passed: 'pass',
|
|
76
|
-
failed: 'fail'
|
|
77
|
-
}
|
|
78
|
-
|
|
79
70
|
const asyncResources = new WeakMap()
|
|
80
71
|
const originalTestFns = new WeakMap()
|
|
81
72
|
const retriedTestsToNumAttempts = new Map()
|
|
@@ -157,7 +148,7 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
|
|
|
157
148
|
}
|
|
158
149
|
let hasSnapshotTests = true
|
|
159
150
|
try {
|
|
160
|
-
const { _snapshotData } = this.
|
|
151
|
+
const { _snapshotData } = this.getVmContext().expect.getState().snapshotState
|
|
161
152
|
hasSnapshotTests = Object.keys(_snapshotData).length > 0
|
|
162
153
|
} catch (e) {
|
|
163
154
|
// if we can't be sure, we'll err on the side of caution and assume it has snapshots
|
|
@@ -837,45 +828,6 @@ addHook({
|
|
|
837
828
|
versions: ['24.8.0 - 24.9.0']
|
|
838
829
|
}, jestConfigSyncWrapper)
|
|
839
830
|
|
|
840
|
-
function jasmineAsyncInstallWraper (jasmineAsyncInstallExport, jestVersion) {
|
|
841
|
-
log.warn('jest-jasmine2 support is removed from dd-trace@v4. Consider changing to jest-circus as `testRunner`.')
|
|
842
|
-
return function (globalConfig, globalInput) {
|
|
843
|
-
globalInput._ddtrace = global._ddtrace
|
|
844
|
-
shimmer.wrap(globalInput.jasmine.Spec.prototype, 'execute', execute => function (onComplete) {
|
|
845
|
-
const asyncResource = new AsyncResource('bound-anonymous-fn')
|
|
846
|
-
asyncResource.runInAsyncScope(() => {
|
|
847
|
-
const testSuite = getTestSuitePath(this.result.testPath, globalConfig.rootDir)
|
|
848
|
-
testStartCh.publish({
|
|
849
|
-
name: this.getFullName(),
|
|
850
|
-
suite: testSuite,
|
|
851
|
-
runner: 'jest-jasmine2',
|
|
852
|
-
frameworkVersion: jestVersion
|
|
853
|
-
})
|
|
854
|
-
const spec = this
|
|
855
|
-
const callback = asyncResource.bind(function () {
|
|
856
|
-
if (spec.result.failedExpectations && spec.result.failedExpectations.length) {
|
|
857
|
-
const formattedError = formatJestError(spec.result.failedExpectations[0].error)
|
|
858
|
-
testErrCh.publish(formattedError)
|
|
859
|
-
}
|
|
860
|
-
testRunFinishCh.publish({ status: specStatusToTestStatus[spec.result.status] })
|
|
861
|
-
onComplete.apply(this, arguments)
|
|
862
|
-
})
|
|
863
|
-
arguments[0] = callback
|
|
864
|
-
execute.apply(this, arguments)
|
|
865
|
-
})
|
|
866
|
-
})
|
|
867
|
-
return jasmineAsyncInstallExport.default(globalConfig, globalInput)
|
|
868
|
-
}
|
|
869
|
-
}
|
|
870
|
-
|
|
871
|
-
if (DD_MAJOR < 4) {
|
|
872
|
-
addHook({
|
|
873
|
-
name: 'jest-jasmine2',
|
|
874
|
-
versions: ['>=24.8.0'],
|
|
875
|
-
file: 'build/jasmineAsyncInstall.js'
|
|
876
|
-
}, jasmineAsyncInstallWraper)
|
|
877
|
-
}
|
|
878
|
-
|
|
879
831
|
const LIBRARIES_BYPASSING_JEST_REQUIRE_ENGINE = [
|
|
880
832
|
'selenium-webdriver'
|
|
881
833
|
]
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const { channel, addHook } = require('./helpers/instrument')
|
|
4
|
+
|
|
5
|
+
const shimmer = require('../../datadog-shimmer')
|
|
6
|
+
|
|
7
|
+
addHook({ name: 'lodash', versions: ['>=4'] }, lodash => {
|
|
8
|
+
const lodashOperationCh = channel('datadog:lodash:operation')
|
|
9
|
+
|
|
10
|
+
const instrumentedLodashFn = ['trim', 'trimStart', 'trimEnd', 'toLower', 'toUpper', 'join']
|
|
11
|
+
|
|
12
|
+
shimmer.massWrap(
|
|
13
|
+
lodash,
|
|
14
|
+
instrumentedLodashFn,
|
|
15
|
+
lodashFn => {
|
|
16
|
+
return function () {
|
|
17
|
+
if (!lodashOperationCh.hasSubscribers) {
|
|
18
|
+
return lodashFn.apply(this, arguments)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const result = lodashFn.apply(this, arguments)
|
|
22
|
+
const message = { operation: lodashFn.name, arguments, result }
|
|
23
|
+
lodashOperationCh.publish(message)
|
|
24
|
+
|
|
25
|
+
return message.result
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
return lodash
|
|
31
|
+
})
|
|
@@ -297,7 +297,12 @@ function dispatcherRunWrapper (run) {
|
|
|
297
297
|
}
|
|
298
298
|
|
|
299
299
|
function dispatcherRunWrapperNew (run) {
|
|
300
|
-
return function () {
|
|
300
|
+
return function (testGroups) {
|
|
301
|
+
if (!this._allTests) {
|
|
302
|
+
// Removed in https://github.com/microsoft/playwright/commit/1e52c37b254a441cccf332520f60225a5acc14c7
|
|
303
|
+
// Not available from >=1.44.0
|
|
304
|
+
this._allTests = testGroups.map(g => g.tests).flat()
|
|
305
|
+
}
|
|
301
306
|
remainingTestsByFile = getTestsBySuiteFromTestGroups(arguments[0])
|
|
302
307
|
return run.apply(this, arguments)
|
|
303
308
|
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const NM = 'node_modules/'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* For a given full path to a module,
|
|
7
|
+
* return the package name it belongs to and the local path to the module
|
|
8
|
+
* input: '/foo/node_modules/@co/stuff/foo/bar/baz.js'
|
|
9
|
+
* output: { pkg: '@co/stuff', path: 'foo/bar/baz.js' }
|
|
10
|
+
*/
|
|
11
|
+
module.exports = function extractPackageAndModulePath (fullPath) {
|
|
12
|
+
const nm = fullPath.lastIndexOf(NM)
|
|
13
|
+
if (nm < 0) {
|
|
14
|
+
return { pkg: null, path: null }
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const subPath = fullPath.substring(nm + NM.length)
|
|
18
|
+
const firstSlash = subPath.indexOf('/')
|
|
19
|
+
|
|
20
|
+
if (subPath[0] === '@') {
|
|
21
|
+
const secondSlash = subPath.substring(firstSlash + 1).indexOf('/')
|
|
22
|
+
|
|
23
|
+
return {
|
|
24
|
+
pkg: subPath.substring(0, firstSlash + 1 + secondSlash),
|
|
25
|
+
path: subPath.substring(firstSlash + 1 + secondSlash + 1)
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return {
|
|
30
|
+
pkg: subPath.substring(0, firstSlash),
|
|
31
|
+
path: subPath.substring(firstSlash + 1)
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -9,6 +9,10 @@ class HardcodedPasswordAnalyzer extends HardcodedBaseAnalyzer {
|
|
|
9
9
|
constructor () {
|
|
10
10
|
super(HARDCODED_PASSWORD, allRules)
|
|
11
11
|
}
|
|
12
|
+
|
|
13
|
+
_getEvidence (value) {
|
|
14
|
+
return { value: `${value.ident}` }
|
|
15
|
+
}
|
|
12
16
|
}
|
|
13
17
|
|
|
14
18
|
module.exports = new HardcodedPasswordAnalyzer()
|
|
@@ -2,35 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
const dc = require('dc-polyfill')
|
|
4
4
|
const log = require('../../log')
|
|
5
|
-
const { calculateDDBasePath } = require('../../util')
|
|
6
5
|
|
|
7
6
|
const telemetryLog = dc.channel('datadog:telemetry:log')
|
|
8
7
|
|
|
9
|
-
const ddBasePath = calculateDDBasePath(__dirname)
|
|
10
|
-
const EOL = '\n'
|
|
11
|
-
const STACK_FRAME_LINE_REGEX = /^\s*at\s/gm
|
|
12
|
-
|
|
13
|
-
function sanitize (logEntry, stack) {
|
|
14
|
-
if (!stack) return logEntry
|
|
15
|
-
|
|
16
|
-
let stackLines = stack.split(EOL)
|
|
17
|
-
|
|
18
|
-
const firstIndex = stackLines.findIndex(l => l.match(STACK_FRAME_LINE_REGEX))
|
|
19
|
-
|
|
20
|
-
const isDDCode = firstIndex > -1 && stackLines[firstIndex].includes(ddBasePath)
|
|
21
|
-
stackLines = stackLines
|
|
22
|
-
.filter((line, index) => (isDDCode && index < firstIndex) || line.includes(ddBasePath))
|
|
23
|
-
.map(line => line.replace(ddBasePath, ''))
|
|
24
|
-
|
|
25
|
-
logEntry.stack_trace = stackLines.join(EOL)
|
|
26
|
-
|
|
27
|
-
if (!isDDCode) {
|
|
28
|
-
logEntry.message = 'omitted'
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
return logEntry
|
|
32
|
-
}
|
|
33
|
-
|
|
34
8
|
function getTelemetryLog (data, level) {
|
|
35
9
|
try {
|
|
36
10
|
data = typeof data === 'function' ? data() : data
|
|
@@ -42,18 +16,13 @@ function getTelemetryLog (data, level) {
|
|
|
42
16
|
message = String(data.message || data)
|
|
43
17
|
}
|
|
44
18
|
|
|
45
|
-
|
|
19
|
+
const logEntry = {
|
|
46
20
|
message,
|
|
47
21
|
level
|
|
48
22
|
}
|
|
49
|
-
|
|
50
23
|
if (data.stack) {
|
|
51
|
-
logEntry =
|
|
52
|
-
if (logEntry.stack_trace === '') {
|
|
53
|
-
return
|
|
54
|
-
}
|
|
24
|
+
logEntry.stack_trace = data.stack
|
|
55
25
|
}
|
|
56
|
-
|
|
57
26
|
return logEntry
|
|
58
27
|
} catch (e) {
|
|
59
28
|
log.error(e)
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const csiMethods = [
|
|
4
4
|
{ src: 'concat' },
|
|
5
|
+
{ src: 'join' },
|
|
5
6
|
{ src: 'parse' },
|
|
6
7
|
{ src: 'plusOperator', operator: true },
|
|
7
8
|
{ src: 'random' },
|
|
@@ -9,6 +10,8 @@ const csiMethods = [
|
|
|
9
10
|
{ src: 'slice' },
|
|
10
11
|
{ src: 'substr' },
|
|
11
12
|
{ src: 'substring' },
|
|
13
|
+
{ src: 'toLowerCase', dst: 'stringCase' },
|
|
14
|
+
{ src: 'toUpperCase', dst: 'stringCase' },
|
|
12
15
|
{ src: 'trim' },
|
|
13
16
|
{ src: 'trimEnd' },
|
|
14
17
|
{ src: 'trimStart', dst: 'trim' }
|
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
+
const dc = require('dc-polyfill')
|
|
3
4
|
const TaintedUtils = require('@datadog/native-iast-taint-tracking')
|
|
4
5
|
const { IAST_TRANSACTION_ID } = require('../iast-context')
|
|
5
6
|
const iastTelemetry = require('../telemetry')
|
|
6
7
|
const { REQUEST_TAINTED } = require('../telemetry/iast-metric')
|
|
7
8
|
const { isInfoAllowed } = require('../telemetry/verbosity')
|
|
8
|
-
const {
|
|
9
|
+
const {
|
|
10
|
+
getTaintTrackingImpl,
|
|
11
|
+
getTaintTrackingNoop,
|
|
12
|
+
lodashTaintTrackingHandler
|
|
13
|
+
} = require('./taint-tracking-impl')
|
|
9
14
|
const { taintObject } = require('./operations-taint-object')
|
|
10
15
|
|
|
16
|
+
const lodashOperationCh = dc.channel('datadog:lodash:operation')
|
|
17
|
+
|
|
11
18
|
function createTransaction (id, iastContext) {
|
|
12
19
|
if (id && iastContext) {
|
|
13
20
|
iastContext[IAST_TRANSACTION_ID] = TaintedUtils.createTransaction(id)
|
|
@@ -92,10 +99,12 @@ function enableTaintOperations (telemetryVerbosity) {
|
|
|
92
99
|
}
|
|
93
100
|
|
|
94
101
|
global._ddiast = getTaintTrackingImpl(telemetryVerbosity)
|
|
102
|
+
lodashOperationCh.subscribe(lodashTaintTrackingHandler)
|
|
95
103
|
}
|
|
96
104
|
|
|
97
105
|
function disableTaintOperations () {
|
|
98
106
|
global._ddiast = getTaintTrackingNoop()
|
|
107
|
+
lodashOperationCh.unsubscribe(lodashTaintTrackingHandler)
|
|
99
108
|
}
|
|
100
109
|
|
|
101
110
|
function setMaxTransactions (transactions) {
|
|
@@ -18,6 +18,7 @@ function noop (res) { return res }
|
|
|
18
18
|
// Otherwise you may end up rewriting a method and not providing its rewritten implementation
|
|
19
19
|
const TaintTrackingNoop = {
|
|
20
20
|
concat: noop,
|
|
21
|
+
join: noop,
|
|
21
22
|
parse: noop,
|
|
22
23
|
plusOperator: noop,
|
|
23
24
|
random: noop,
|
|
@@ -25,6 +26,7 @@ const TaintTrackingNoop = {
|
|
|
25
26
|
slice: noop,
|
|
26
27
|
substr: noop,
|
|
27
28
|
substring: noop,
|
|
29
|
+
stringCase: noop,
|
|
28
30
|
trim: noop,
|
|
29
31
|
trimEnd: noop
|
|
30
32
|
}
|
|
@@ -113,6 +115,13 @@ function csiMethodsOverrides (getContext) {
|
|
|
113
115
|
return res
|
|
114
116
|
},
|
|
115
117
|
|
|
118
|
+
stringCase: getCsiFn(
|
|
119
|
+
(transactionId, res, target) => TaintedUtils.stringCase(transactionId, res, target),
|
|
120
|
+
getContext,
|
|
121
|
+
String.prototype.toLowerCase,
|
|
122
|
+
String.prototype.toUpperCase
|
|
123
|
+
),
|
|
124
|
+
|
|
116
125
|
trim: getCsiFn(
|
|
117
126
|
(transactionId, res, target) => TaintedUtils.trim(transactionId, res, target),
|
|
118
127
|
getContext,
|
|
@@ -147,6 +156,22 @@ function csiMethodsOverrides (getContext) {
|
|
|
147
156
|
}
|
|
148
157
|
}
|
|
149
158
|
|
|
159
|
+
return res
|
|
160
|
+
},
|
|
161
|
+
|
|
162
|
+
join: function (res, fn, target, separator) {
|
|
163
|
+
if (fn === Array.prototype.join) {
|
|
164
|
+
try {
|
|
165
|
+
const iastContext = getContext()
|
|
166
|
+
const transactionId = getTransactionId(iastContext)
|
|
167
|
+
if (transactionId) {
|
|
168
|
+
res = TaintedUtils.arrayJoin(transactionId, res, target, separator)
|
|
169
|
+
}
|
|
170
|
+
} catch (e) {
|
|
171
|
+
iastLog.error(e)
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
150
175
|
return res
|
|
151
176
|
}
|
|
152
177
|
}
|
|
@@ -176,7 +201,36 @@ function getTaintTrackingNoop () {
|
|
|
176
201
|
return getTaintTrackingImpl(null, true)
|
|
177
202
|
}
|
|
178
203
|
|
|
204
|
+
const lodashFns = {
|
|
205
|
+
join: TaintedUtils.arrayJoin,
|
|
206
|
+
toLower: TaintedUtils.stringCase,
|
|
207
|
+
toUpper: TaintedUtils.stringCase,
|
|
208
|
+
trim: TaintedUtils.trim,
|
|
209
|
+
trimEnd: TaintedUtils.trimEnd,
|
|
210
|
+
trimStart: TaintedUtils.trim
|
|
211
|
+
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
function getLodashTaintedUtilFn (lodashFn) {
|
|
215
|
+
return lodashFns[lodashFn] || ((transactionId, result) => result)
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
function lodashTaintTrackingHandler (message) {
|
|
219
|
+
try {
|
|
220
|
+
if (!message.result) return
|
|
221
|
+
const context = getContextDefault()
|
|
222
|
+
const transactionId = getTransactionId(context)
|
|
223
|
+
if (transactionId) {
|
|
224
|
+
message.result = getLodashTaintedUtilFn(message.operation)(transactionId, message.result, ...message.arguments)
|
|
225
|
+
}
|
|
226
|
+
} catch (e) {
|
|
227
|
+
iastLog.error(`Error invoking CSI lodash ${message.operation}`)
|
|
228
|
+
.errorAndPublish(e)
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
179
232
|
module.exports = {
|
|
180
233
|
getTaintTrackingImpl,
|
|
181
|
-
getTaintTrackingNoop
|
|
234
|
+
getTaintTrackingNoop,
|
|
235
|
+
lodashTaintTrackingHandler
|
|
182
236
|
}
|
|
@@ -6,6 +6,7 @@ const vulnerabilities = require('../../vulnerabilities')
|
|
|
6
6
|
const { contains, intersects, remove } = require('./range-utils')
|
|
7
7
|
|
|
8
8
|
const commandSensitiveAnalyzer = require('./sensitive-analyzers/command-sensitive-analyzer')
|
|
9
|
+
const hardcodedPasswordAnalyzer = require('./sensitive-analyzers/hardcoded-password-analyzer')
|
|
9
10
|
const headerSensitiveAnalyzer = require('./sensitive-analyzers/header-sensitive-analyzer')
|
|
10
11
|
const jsonSensitiveAnalyzer = require('./sensitive-analyzers/json-sensitive-analyzer')
|
|
11
12
|
const ldapSensitiveAnalyzer = require('./sensitive-analyzers/ldap-sensitive-analyzer')
|
|
@@ -31,6 +32,9 @@ class SensitiveHandler {
|
|
|
31
32
|
this._sensitiveAnalyzers.set(vulnerabilities.HEADER_INJECTION, (evidence) => {
|
|
32
33
|
return headerSensitiveAnalyzer(evidence, this._namePattern, this._valuePattern)
|
|
33
34
|
})
|
|
35
|
+
this._sensitiveAnalyzers.set(vulnerabilities.HARDCODED_PASSWORD, (evidence) => {
|
|
36
|
+
return hardcodedPasswordAnalyzer(evidence, this._valuePattern)
|
|
37
|
+
})
|
|
34
38
|
}
|
|
35
39
|
|
|
36
40
|
isSensibleName (name) {
|
|
@@ -51,7 +55,9 @@ class SensitiveHandler {
|
|
|
51
55
|
const sensitiveAnalyzer = this._sensitiveAnalyzers.get(vulnerabilityType)
|
|
52
56
|
if (sensitiveAnalyzer) {
|
|
53
57
|
const sensitiveRanges = sensitiveAnalyzer(evidence)
|
|
54
|
-
|
|
58
|
+
if (evidence.ranges || sensitiveRanges?.length) {
|
|
59
|
+
return this.toRedactedJson(evidence, sensitiveRanges, sourcesIndexes, sources)
|
|
60
|
+
}
|
|
55
61
|
}
|
|
56
62
|
return null
|
|
57
63
|
}
|
|
@@ -67,7 +73,7 @@ class SensitiveHandler {
|
|
|
67
73
|
let nextTaintedIndex = 0
|
|
68
74
|
let sourceIndex
|
|
69
75
|
|
|
70
|
-
let nextTainted = ranges
|
|
76
|
+
let nextTainted = ranges?.shift()
|
|
71
77
|
let nextSensitive = sensitive.shift()
|
|
72
78
|
|
|
73
79
|
for (let i = 0; i < value.length; i++) {
|
|
@@ -49,6 +49,10 @@ class VulnerabilityFormatter {
|
|
|
49
49
|
evidence.ranges = ranges
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
+
if (!evidence.ranges) {
|
|
53
|
+
return { value: evidence.value }
|
|
54
|
+
}
|
|
55
|
+
|
|
52
56
|
evidence.ranges.forEach((range, rangeIndex) => {
|
|
53
57
|
if (fromIndex < range.start) {
|
|
54
58
|
valueParts.push({ value: evidence.value.substring(fromIndex, range.start) })
|
|
@@ -65,12 +69,8 @@ class VulnerabilityFormatter {
|
|
|
65
69
|
}
|
|
66
70
|
|
|
67
71
|
formatEvidence (type, evidence, sourcesIndexes, sources) {
|
|
68
|
-
if (
|
|
69
|
-
|
|
70
|
-
return undefined
|
|
71
|
-
} else {
|
|
72
|
-
return { value: evidence.value }
|
|
73
|
-
}
|
|
72
|
+
if (typeof evidence.value === 'undefined') {
|
|
73
|
+
return undefined
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
return this._redactVulnearbilities
|
|
@@ -16,7 +16,7 @@ const { GIT_REPOSITORY_URL, GIT_COMMIT_SHA } = require('./plugins/util/tags')
|
|
|
16
16
|
const { getGitMetadataFromGitProperties, removeUserSensitiveInfo } = require('./git_properties')
|
|
17
17
|
const { updateConfig } = require('./telemetry')
|
|
18
18
|
const telemetryMetrics = require('./telemetry/metrics')
|
|
19
|
-
const { getIsGCPFunction,
|
|
19
|
+
const { getIsGCPFunction, getIsAzureFunction } = require('./serverless')
|
|
20
20
|
const { ORIGIN_KEY } = require('./constants')
|
|
21
21
|
|
|
22
22
|
const tracerMetrics = telemetryMetrics.manager.namespace('tracers')
|
|
@@ -339,7 +339,7 @@ class Config {
|
|
|
339
339
|
|
|
340
340
|
// Requires an accompanying DD_APM_OBFUSCATION_MEMCACHED_KEEP_COMMAND=true in the agent
|
|
341
341
|
this.memcachedCommandEnabled = isTrue(DD_TRACE_MEMCACHED_COMMAND_ENABLED)
|
|
342
|
-
this.
|
|
342
|
+
this.isAzureFunction = getIsAzureFunction()
|
|
343
343
|
this.spanLeakDebug = Number(DD_TRACE_SPAN_LEAK_DEBUG)
|
|
344
344
|
this.installSignature = {
|
|
345
345
|
id: DD_INSTRUMENTATION_INSTALL_ID,
|
|
@@ -417,8 +417,8 @@ class Config {
|
|
|
417
417
|
_isInServerlessEnvironment () {
|
|
418
418
|
const inAWSLambda = process.env.AWS_LAMBDA_FUNCTION_NAME !== undefined
|
|
419
419
|
const isGCPFunction = getIsGCPFunction()
|
|
420
|
-
const
|
|
421
|
-
return inAWSLambda || isGCPFunction ||
|
|
420
|
+
const isAzureFunction = getIsAzureFunction()
|
|
421
|
+
return inAWSLambda || isGCPFunction || isAzureFunction
|
|
422
422
|
}
|
|
423
423
|
|
|
424
424
|
// for _merge to work, every config value must have a default value
|
|
@@ -446,6 +446,7 @@ class Config {
|
|
|
446
446
|
this._setValue(defaults, 'appsec.obfuscatorValueRegex', defaultWafObfuscatorValueRegex)
|
|
447
447
|
this._setValue(defaults, 'appsec.rateLimit', 100)
|
|
448
448
|
this._setValue(defaults, 'appsec.rules', undefined)
|
|
449
|
+
this._setValue(defaults, 'appsec.sca.enabled', null)
|
|
449
450
|
this._setValue(defaults, 'appsec.wafTimeout', 5e3) // µs
|
|
450
451
|
this._setValue(defaults, 'clientIpEnabled', false)
|
|
451
452
|
this._setValue(defaults, 'clientIpHeader', null)
|
|
@@ -516,6 +517,7 @@ class Config {
|
|
|
516
517
|
this._setValue(defaults, 'tracing', true)
|
|
517
518
|
this._setValue(defaults, 'url', undefined)
|
|
518
519
|
this._setValue(defaults, 'version', pkg.version)
|
|
520
|
+
this._setValue(defaults, 'instrumentation_config_id', undefined)
|
|
519
521
|
}
|
|
520
522
|
|
|
521
523
|
_applyEnvironment () {
|
|
@@ -528,6 +530,7 @@ class Config {
|
|
|
528
530
|
DD_APPSEC_OBFUSCATION_PARAMETER_KEY_REGEXP,
|
|
529
531
|
DD_APPSEC_OBFUSCATION_PARAMETER_VALUE_REGEXP,
|
|
530
532
|
DD_APPSEC_RULES,
|
|
533
|
+
DD_APPSEC_SCA_ENABLED,
|
|
531
534
|
DD_APPSEC_TRACE_RATE_LIMIT,
|
|
532
535
|
DD_APPSEC_WAF_TIMEOUT,
|
|
533
536
|
DD_DATA_STREAMS_ENABLED,
|
|
@@ -546,7 +549,9 @@ class Config {
|
|
|
546
549
|
DD_IAST_REDACTION_VALUE_PATTERN,
|
|
547
550
|
DD_IAST_REQUEST_SAMPLING,
|
|
548
551
|
DD_IAST_TELEMETRY_VERBOSITY,
|
|
552
|
+
DD_INJECTION_ENABLED,
|
|
549
553
|
DD_INSTRUMENTATION_TELEMETRY_ENABLED,
|
|
554
|
+
DD_INSTRUMENTATION_CONFIG_ID,
|
|
550
555
|
DD_LOGS_INJECTION,
|
|
551
556
|
DD_OPENAI_LOGS_ENABLED,
|
|
552
557
|
DD_OPENAI_SPAN_CHAR_LIMIT,
|
|
@@ -615,6 +620,8 @@ class Config {
|
|
|
615
620
|
this._setString(env, 'appsec.obfuscatorValueRegex', DD_APPSEC_OBFUSCATION_PARAMETER_VALUE_REGEXP)
|
|
616
621
|
this._setValue(env, 'appsec.rateLimit', maybeInt(DD_APPSEC_TRACE_RATE_LIMIT))
|
|
617
622
|
this._setString(env, 'appsec.rules', DD_APPSEC_RULES)
|
|
623
|
+
// DD_APPSEC_SCA_ENABLED is never used locally, but only sent to the backend
|
|
624
|
+
this._setBoolean(env, 'appsec.sca.enabled', DD_APPSEC_SCA_ENABLED)
|
|
618
625
|
this._setValue(env, 'appsec.wafTimeout', maybeInt(DD_APPSEC_WAF_TIMEOUT))
|
|
619
626
|
this._setBoolean(env, 'clientIpEnabled', DD_TRACE_CLIENT_IP_ENABLED)
|
|
620
627
|
this._setString(env, 'clientIpHeader', DD_TRACE_CLIENT_IP_HEADER)
|
|
@@ -695,10 +702,18 @@ class Config {
|
|
|
695
702
|
DD_INSTRUMENTATION_TELEMETRY_ENABLED, // to comply with instrumentation telemetry specs
|
|
696
703
|
!(this._isInServerlessEnvironment() || JEST_WORKER_ID)
|
|
697
704
|
))
|
|
705
|
+
this._setString(env, 'instrumentation_config_id', DD_INSTRUMENTATION_CONFIG_ID)
|
|
698
706
|
this._setBoolean(env, 'telemetry.debug', DD_TELEMETRY_DEBUG)
|
|
699
707
|
this._setBoolean(env, 'telemetry.dependencyCollection', DD_TELEMETRY_DEPENDENCY_COLLECTION_ENABLED)
|
|
700
708
|
this._setValue(env, 'telemetry.heartbeatInterval', maybeInt(Math.floor(DD_TELEMETRY_HEARTBEAT_INTERVAL * 1000)))
|
|
701
|
-
|
|
709
|
+
const hasTelemetryLogsUsingFeatures =
|
|
710
|
+
isTrue(DD_IAST_ENABLED) ||
|
|
711
|
+
isTrue(DD_PROFILING_ENABLED) ||
|
|
712
|
+
(typeof DD_INJECTION_ENABLED === 'string' && DD_INJECTION_ENABLED.split(',').includes('profiling'))
|
|
713
|
+
? true
|
|
714
|
+
: undefined
|
|
715
|
+
this._setBoolean(env, 'telemetry.logCollection', coalesce(DD_TELEMETRY_LOG_COLLECTION_ENABLED,
|
|
716
|
+
hasTelemetryLogsUsingFeatures))
|
|
702
717
|
this._setBoolean(env, 'telemetry.metrics', DD_TELEMETRY_METRICS_ENABLED)
|
|
703
718
|
this._setBoolean(env, 'traceId128BitGenerationEnabled', DD_TRACE_128_BIT_TRACEID_GENERATION_ENABLED)
|
|
704
719
|
this._setBoolean(env, 'traceId128BitLoggingEnabled', DD_TRACE_128_BIT_TRACEID_LOGGING_ENABLED)
|
|
@@ -779,8 +794,10 @@ class Config {
|
|
|
779
794
|
this._setBoolean(opts, 'spanRemoveIntegrationFromService', options.spanRemoveIntegrationFromService)
|
|
780
795
|
this._setBoolean(opts, 'startupLogs', options.startupLogs)
|
|
781
796
|
this._setTags(opts, 'tags', tags)
|
|
782
|
-
|
|
783
|
-
|
|
797
|
+
const hasTelemetryLogsUsingFeatures =
|
|
798
|
+
(options.iastOptions && (options.iastOptions === true || options.iastOptions?.enabled === true)) ||
|
|
799
|
+
(options.profiling && options.profiling === true)
|
|
800
|
+
this._setBoolean(opts, 'telemetry.logCollection', hasTelemetryLogsUsingFeatures)
|
|
784
801
|
this._setBoolean(opts, 'traceId128BitGenerationEnabled', options.traceId128BitGenerationEnabled)
|
|
785
802
|
this._setBoolean(opts, 'traceId128BitLoggingEnabled', options.traceId128BitLoggingEnabled)
|
|
786
803
|
this._setString(opts, 'version', options.version || tags.version)
|
|
@@ -860,7 +877,7 @@ class Config {
|
|
|
860
877
|
return coalesce(
|
|
861
878
|
this.options.stats,
|
|
862
879
|
process.env.DD_TRACE_STATS_COMPUTATION_ENABLED,
|
|
863
|
-
getIsGCPFunction() ||
|
|
880
|
+
getIsGCPFunction() || getIsAzureFunction()
|
|
864
881
|
)
|
|
865
882
|
}
|
|
866
883
|
|
|
@@ -83,13 +83,17 @@ class AgentEncoder {
|
|
|
83
83
|
span = formatSpan(span)
|
|
84
84
|
bytes.reserve(1)
|
|
85
85
|
|
|
86
|
-
if (span.type) {
|
|
86
|
+
if (span.type && span.meta_struct) {
|
|
87
|
+
bytes.buffer[bytes.length++] = 0x8d
|
|
88
|
+
} else if (span.type || span.meta_struct) {
|
|
87
89
|
bytes.buffer[bytes.length++] = 0x8c
|
|
90
|
+
} else {
|
|
91
|
+
bytes.buffer[bytes.length++] = 0x8b
|
|
92
|
+
}
|
|
88
93
|
|
|
94
|
+
if (span.type) {
|
|
89
95
|
this._encodeString(bytes, 'type')
|
|
90
96
|
this._encodeString(bytes, span.type)
|
|
91
|
-
} else {
|
|
92
|
-
bytes.buffer[bytes.length++] = 0x8b
|
|
93
97
|
}
|
|
94
98
|
|
|
95
99
|
this._encodeString(bytes, 'trace_id')
|
|
@@ -114,6 +118,10 @@ class AgentEncoder {
|
|
|
114
118
|
this._encodeMap(bytes, span.meta)
|
|
115
119
|
this._encodeString(bytes, 'metrics')
|
|
116
120
|
this._encodeMap(bytes, span.metrics)
|
|
121
|
+
if (span.meta_struct) {
|
|
122
|
+
this._encodeString(bytes, 'meta_struct')
|
|
123
|
+
this._encodeObject(bytes, span.meta_struct)
|
|
124
|
+
}
|
|
117
125
|
}
|
|
118
126
|
}
|
|
119
127
|
|
|
@@ -263,6 +271,45 @@ class AgentEncoder {
|
|
|
263
271
|
}
|
|
264
272
|
}
|
|
265
273
|
|
|
274
|
+
_encodeObject (bytes, value, circularReferencesDetector = new Set()) {
|
|
275
|
+
circularReferencesDetector.add(value)
|
|
276
|
+
if (Array.isArray(value)) {
|
|
277
|
+
return this._encodeObjectAsArray(bytes, value, circularReferencesDetector)
|
|
278
|
+
} else if (value !== null && typeof value === 'object') {
|
|
279
|
+
return this._encodeObjectAsMap(bytes, value, circularReferencesDetector)
|
|
280
|
+
} else if (typeof value === 'string' || typeof value === 'number') {
|
|
281
|
+
this._encodeValue(bytes, value)
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
_encodeObjectAsMap (bytes, value, circularReferencesDetector) {
|
|
286
|
+
const keys = Object.keys(value)
|
|
287
|
+
const validKeys = keys.filter(key =>
|
|
288
|
+
typeof value[key] === 'string' ||
|
|
289
|
+
typeof value[key] === 'number' ||
|
|
290
|
+
(value[key] !== null && typeof value[key] === 'object' && !circularReferencesDetector.has(value[key])))
|
|
291
|
+
|
|
292
|
+
this._encodeMapPrefix(bytes, validKeys.length)
|
|
293
|
+
|
|
294
|
+
for (const key of validKeys) {
|
|
295
|
+
this._encodeString(bytes, key)
|
|
296
|
+
this._encodeObject(bytes, value[key], circularReferencesDetector)
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
_encodeObjectAsArray (bytes, value, circularReferencesDetector) {
|
|
301
|
+
const validValue = value.filter(item =>
|
|
302
|
+
typeof item === 'string' ||
|
|
303
|
+
typeof item === 'number' ||
|
|
304
|
+
(item !== null && typeof item === 'object' && !circularReferencesDetector.has(item)))
|
|
305
|
+
|
|
306
|
+
this._encodeArrayPrefix(bytes, validValue)
|
|
307
|
+
|
|
308
|
+
for (const item of validValue) {
|
|
309
|
+
this._encodeObject(bytes, item, circularReferencesDetector)
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
266
313
|
_cacheString (value) {
|
|
267
314
|
if (!(value in this._stringMap)) {
|
|
268
315
|
this._stringCount++
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
const StoragePlugin = require('./storage')
|
|
4
|
-
const { PEER_SERVICE_KEY } = require('../constants')
|
|
4
|
+
const { PEER_SERVICE_KEY, PEER_SERVICE_SOURCE_KEY } = require('../constants')
|
|
5
5
|
|
|
6
6
|
class DatabasePlugin extends StoragePlugin {
|
|
7
7
|
static get operation () { return 'query' }
|
|
@@ -28,16 +28,31 @@ class DatabasePlugin extends StoragePlugin {
|
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
createDBMPropagationCommentService (serviceName) {
|
|
31
|
+
createDBMPropagationCommentService (serviceName, span) {
|
|
32
32
|
this.encodingServiceTags('dddbs', 'encodedDddbs', serviceName)
|
|
33
33
|
this.encodingServiceTags('dde', 'encodedDde', this.tracer._env)
|
|
34
34
|
this.encodingServiceTags('ddps', 'encodedDdps', this.tracer._service)
|
|
35
35
|
this.encodingServiceTags('ddpv', 'encodedDdpv', this.tracer._version)
|
|
36
|
+
if (span.context()._tags['out.host']) {
|
|
37
|
+
this.encodingServiceTags('ddh', 'encodedDdh', span._spanContext._tags['out.host'])
|
|
38
|
+
}
|
|
39
|
+
if (span.context()._tags['db.name']) {
|
|
40
|
+
this.encodingServiceTags('dddb', 'encodedDddb', span._spanContext._tags['db.name'])
|
|
41
|
+
}
|
|
36
42
|
|
|
37
|
-
const { encodedDddbs, encodedDde, encodedDdps, encodedDdpv } = this.serviceTags
|
|
43
|
+
const { encodedDddb, encodedDddbs, encodedDde, encodedDdh, encodedDdps, encodedDdpv } = this.serviceTags
|
|
38
44
|
|
|
39
|
-
|
|
45
|
+
let dbmComment = `dddb='${encodedDddb}',dddbs='${encodedDddbs}',dde='${encodedDde}',ddh='${encodedDdh}',` +
|
|
40
46
|
`ddps='${encodedDdps}',ddpv='${encodedDdpv}'`
|
|
47
|
+
|
|
48
|
+
const peerData = this.getPeerService(span.context()._tags)
|
|
49
|
+
if (peerData !== undefined && peerData[PEER_SERVICE_SOURCE_KEY] === PEER_SERVICE_KEY) {
|
|
50
|
+
this.encodingServiceTags('ddprs', 'encodedDdprs', peerData[PEER_SERVICE_KEY])
|
|
51
|
+
|
|
52
|
+
const { encodedDdprs } = this.serviceTags
|
|
53
|
+
dbmComment += `,ddprs='${encodedDdprs}'`
|
|
54
|
+
}
|
|
55
|
+
return dbmComment
|
|
41
56
|
}
|
|
42
57
|
|
|
43
58
|
getDbmServiceName (span, tracerService) {
|
|
@@ -56,7 +71,7 @@ class DatabasePlugin extends StoragePlugin {
|
|
|
56
71
|
return query
|
|
57
72
|
}
|
|
58
73
|
|
|
59
|
-
const servicePropagation = this.createDBMPropagationCommentService(dbmService)
|
|
74
|
+
const servicePropagation = this.createDBMPropagationCommentService(dbmService, span)
|
|
60
75
|
|
|
61
76
|
if (isPreparedStatement || mode === 'service') {
|
|
62
77
|
return `/*${servicePropagation}*/ ${query}`
|
|
@@ -44,7 +44,6 @@ module.exports = {
|
|
|
44
44
|
get 'jest-config' () { return require('../../../datadog-plugin-jest/src') },
|
|
45
45
|
get 'jest-environment-node' () { return require('../../../datadog-plugin-jest/src') },
|
|
46
46
|
get 'jest-environment-jsdom' () { return require('../../../datadog-plugin-jest/src') },
|
|
47
|
-
get 'jest-jasmine2' () { return require('../../../datadog-plugin-jest/src') },
|
|
48
47
|
get 'jest-runtime' () { return require('../../../datadog-plugin-jest/src') },
|
|
49
48
|
get 'jest-worker' () { return require('../../../datadog-plugin-jest/src') },
|
|
50
49
|
get koa () { return require('../../../datadog-plugin-koa/src') },
|
|
@@ -5,6 +5,7 @@ const { Config } = require('./config')
|
|
|
5
5
|
const { snapshotKinds } = require('./constants')
|
|
6
6
|
const { threadNamePrefix } = require('./profilers/shared')
|
|
7
7
|
const dc = require('dc-polyfill')
|
|
8
|
+
const telemetryLog = dc.channel('datadog:telemetry:log')
|
|
8
9
|
|
|
9
10
|
const profileSubmittedChannel = dc.channel('datadog:profiling:profile-submitted')
|
|
10
11
|
|
|
@@ -15,6 +16,19 @@ function maybeSourceMap (sourceMap, SourceMapper, debug) {
|
|
|
15
16
|
], debug)
|
|
16
17
|
}
|
|
17
18
|
|
|
19
|
+
function logError (logger, err) {
|
|
20
|
+
if (logger) {
|
|
21
|
+
logger.error(err)
|
|
22
|
+
}
|
|
23
|
+
if (telemetryLog.hasSubscribers) {
|
|
24
|
+
telemetryLog.publish({
|
|
25
|
+
message: err.message,
|
|
26
|
+
level: 'ERROR',
|
|
27
|
+
stack_trace: err.stack
|
|
28
|
+
})
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
18
32
|
class Profiler extends EventEmitter {
|
|
19
33
|
constructor () {
|
|
20
34
|
super()
|
|
@@ -28,13 +42,15 @@ class Profiler extends EventEmitter {
|
|
|
28
42
|
|
|
29
43
|
start (options) {
|
|
30
44
|
return this._start(options).catch((err) => {
|
|
31
|
-
|
|
32
|
-
options.logger.error(err)
|
|
33
|
-
}
|
|
45
|
+
logError(options.logger, err)
|
|
34
46
|
return false
|
|
35
47
|
})
|
|
36
48
|
}
|
|
37
49
|
|
|
50
|
+
_logError (err) {
|
|
51
|
+
logError(this._logger, err)
|
|
52
|
+
}
|
|
53
|
+
|
|
38
54
|
async _start (options) {
|
|
39
55
|
if (this._enabled) return true
|
|
40
56
|
|
|
@@ -61,7 +77,7 @@ class Profiler extends EventEmitter {
|
|
|
61
77
|
})
|
|
62
78
|
}
|
|
63
79
|
} catch (err) {
|
|
64
|
-
this.
|
|
80
|
+
this._logError(err)
|
|
65
81
|
}
|
|
66
82
|
|
|
67
83
|
try {
|
|
@@ -78,7 +94,7 @@ class Profiler extends EventEmitter {
|
|
|
78
94
|
this._capture(this._timeoutInterval, start)
|
|
79
95
|
return true
|
|
80
96
|
} catch (e) {
|
|
81
|
-
this.
|
|
97
|
+
this._logError(e)
|
|
82
98
|
this._stop()
|
|
83
99
|
return false
|
|
84
100
|
}
|
|
@@ -167,7 +183,7 @@ class Profiler extends EventEmitter {
|
|
|
167
183
|
profileSubmittedChannel.publish()
|
|
168
184
|
this._logger.debug('Submitted profiles')
|
|
169
185
|
} catch (err) {
|
|
170
|
-
this.
|
|
186
|
+
this._logError(err)
|
|
171
187
|
this._stop()
|
|
172
188
|
}
|
|
173
189
|
}
|
|
@@ -182,7 +198,7 @@ class Profiler extends EventEmitter {
|
|
|
182
198
|
tags.snapshot = snapshotKind
|
|
183
199
|
for (const exporter of this._config.exporters) {
|
|
184
200
|
const task = exporter.export({ profiles, start, end, tags })
|
|
185
|
-
.catch(err => this.
|
|
201
|
+
.catch(err => this._logError(err))
|
|
186
202
|
|
|
187
203
|
tasks.push(task)
|
|
188
204
|
}
|
|
@@ -14,6 +14,7 @@ const dogstatsd = require('./dogstatsd')
|
|
|
14
14
|
const NoopDogStatsDClient = require('./noop/dogstatsd')
|
|
15
15
|
const spanleak = require('./spanleak')
|
|
16
16
|
const { SSITelemetry } = require('./profiling/ssi-telemetry')
|
|
17
|
+
const telemetryLog = require('dc-polyfill').channel('datadog:telemetry:log')
|
|
17
18
|
|
|
18
19
|
class LazyModule {
|
|
19
20
|
constructor (provider) {
|
|
@@ -91,7 +92,7 @@ class Tracer extends NoopProxy {
|
|
|
91
92
|
})
|
|
92
93
|
}
|
|
93
94
|
|
|
94
|
-
if (config.isGCPFunction || config.
|
|
95
|
+
if (config.isGCPFunction || config.isAzureFunction) {
|
|
95
96
|
require('./serverless').maybeStartServerlessMiniAgent(config)
|
|
96
97
|
}
|
|
97
98
|
|
|
@@ -104,6 +105,11 @@ class Tracer extends NoopProxy {
|
|
|
104
105
|
this._profilerStarted = profiler.start(config)
|
|
105
106
|
} catch (e) {
|
|
106
107
|
log.error(e)
|
|
108
|
+
telemetryLog.publish({
|
|
109
|
+
message: e.message,
|
|
110
|
+
level: 'ERROR',
|
|
111
|
+
stack_trace: e.stack
|
|
112
|
+
})
|
|
107
113
|
}
|
|
108
114
|
} else if (ssiTelemetry.enabled()) {
|
|
109
115
|
require('./profiling/ssi-telemetry-mock-profiler').start(config)
|
|
@@ -53,18 +53,16 @@ function getIsGCPFunction () {
|
|
|
53
53
|
return isDeprecatedGCPFunction || isNewerGCPFunction
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
function
|
|
56
|
+
function getIsAzureFunction () {
|
|
57
57
|
const isAzureFunction =
|
|
58
58
|
process.env.FUNCTIONS_EXTENSION_VERSION !== undefined && process.env.FUNCTIONS_WORKER_RUNTIME !== undefined
|
|
59
|
-
const azureWebsiteSKU = process.env.WEBSITE_SKU
|
|
60
|
-
const isConsumptionPlan = azureWebsiteSKU === undefined || azureWebsiteSKU === 'Dynamic'
|
|
61
59
|
|
|
62
|
-
return isAzureFunction
|
|
60
|
+
return isAzureFunction
|
|
63
61
|
}
|
|
64
62
|
|
|
65
63
|
module.exports = {
|
|
66
64
|
maybeStartServerlessMiniAgent,
|
|
67
65
|
getIsGCPFunction,
|
|
68
|
-
|
|
66
|
+
getIsAzureFunction,
|
|
69
67
|
getRustBinaryPath
|
|
70
68
|
}
|
|
@@ -6,7 +6,8 @@ const dependencies = require('./dependencies')
|
|
|
6
6
|
const { sendData } = require('./send-data')
|
|
7
7
|
const { errors } = require('../startup-log')
|
|
8
8
|
const { manager: metricsManager } = require('./metrics')
|
|
9
|
-
const
|
|
9
|
+
const telemetryLogger = require('./logs')
|
|
10
|
+
const logger = require('../log')
|
|
10
11
|
|
|
11
12
|
const telemetryStartChannel = dc.channel('datadog:telemetry:start')
|
|
12
13
|
const telemetryStopChannel = dc.channel('datadog:telemetry:stop')
|
|
@@ -211,7 +212,7 @@ function createPayload (currReqType, currPayload = {}) {
|
|
|
211
212
|
function heartbeat (config, application, host) {
|
|
212
213
|
heartbeatTimeout = setTimeout(() => {
|
|
213
214
|
metricsManager.send(config, application, host)
|
|
214
|
-
|
|
215
|
+
telemetryLogger.send(config, application, host)
|
|
215
216
|
|
|
216
217
|
const { reqType, payload } = createPayload('app-heartbeat')
|
|
217
218
|
sendData(config, application, host, reqType, payload, updateRetryData)
|
|
@@ -235,6 +236,10 @@ function extendedHeartbeat (config) {
|
|
|
235
236
|
|
|
236
237
|
function start (aConfig, thePluginManager) {
|
|
237
238
|
if (!aConfig.telemetry.enabled) {
|
|
239
|
+
if (aConfig.sca?.enabled) {
|
|
240
|
+
logger.warn('DD_APPSEC_SCA_ENABLED requires enabling telemetry to work.')
|
|
241
|
+
}
|
|
242
|
+
|
|
238
243
|
return
|
|
239
244
|
}
|
|
240
245
|
config = aConfig
|
|
@@ -245,7 +250,7 @@ function start (aConfig, thePluginManager) {
|
|
|
245
250
|
integrations = getIntegrations()
|
|
246
251
|
|
|
247
252
|
dependencies.start(config, application, host, getRetryData, updateRetryData)
|
|
248
|
-
|
|
253
|
+
telemetryLogger.start(config)
|
|
249
254
|
|
|
250
255
|
sendData(config, application, host, 'app-started', appStarted(config))
|
|
251
256
|
|
|
@@ -318,6 +323,7 @@ function updateConfig (changes, config) {
|
|
|
318
323
|
|
|
319
324
|
for (const change of changes) {
|
|
320
325
|
const name = nameMapping[change.name] || change.name
|
|
326
|
+
|
|
321
327
|
names.push(name)
|
|
322
328
|
const { origin, value } = change
|
|
323
329
|
const entry = { name, value, origin }
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
const log = require('../../log')
|
|
4
|
+
const { calculateDDBasePath } = require('../../util')
|
|
4
5
|
|
|
5
6
|
const logs = new Map()
|
|
6
7
|
|
|
@@ -29,6 +30,37 @@ function isValid (logEntry) {
|
|
|
29
30
|
return logEntry?.level && logEntry.message
|
|
30
31
|
}
|
|
31
32
|
|
|
33
|
+
const ddBasePath = calculateDDBasePath(__dirname)
|
|
34
|
+
const EOL = '\n'
|
|
35
|
+
const STACK_FRAME_LINE_REGEX = /^\s*at\s/gm
|
|
36
|
+
|
|
37
|
+
function sanitize (logEntry) {
|
|
38
|
+
const stack = logEntry.stack_trace
|
|
39
|
+
if (!stack) return logEntry
|
|
40
|
+
|
|
41
|
+
let stackLines = stack.split(EOL)
|
|
42
|
+
|
|
43
|
+
const firstIndex = stackLines.findIndex(l => l.match(STACK_FRAME_LINE_REGEX))
|
|
44
|
+
|
|
45
|
+
const isDDCode = firstIndex > -1 && stackLines[firstIndex].includes(ddBasePath)
|
|
46
|
+
stackLines = stackLines
|
|
47
|
+
.filter((line, index) => (isDDCode && index < firstIndex) || line.includes(ddBasePath))
|
|
48
|
+
.map(line => line.replace(ddBasePath, ''))
|
|
49
|
+
|
|
50
|
+
logEntry.stack_trace = stackLines.join(EOL)
|
|
51
|
+
if (logEntry.stack_trace === '') {
|
|
52
|
+
// If entire stack was removed, we'd just have a message saying "omitted"
|
|
53
|
+
// in which case we'd rather not log it at all.
|
|
54
|
+
return null
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (!isDDCode) {
|
|
58
|
+
logEntry.message = 'omitted'
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return logEntry
|
|
62
|
+
}
|
|
63
|
+
|
|
32
64
|
const logCollector = {
|
|
33
65
|
add (logEntry) {
|
|
34
66
|
try {
|
|
@@ -37,9 +69,13 @@ const logCollector = {
|
|
|
37
69
|
// NOTE: should errors have higher priority? and discard log entries with lower priority?
|
|
38
70
|
if (logs.size >= maxEntries) {
|
|
39
71
|
overflowedCount++
|
|
40
|
-
return
|
|
72
|
+
return false
|
|
41
73
|
}
|
|
42
74
|
|
|
75
|
+
logEntry = sanitize(logEntry)
|
|
76
|
+
if (!logEntry) {
|
|
77
|
+
return false
|
|
78
|
+
}
|
|
43
79
|
const hash = createHash(logEntry)
|
|
44
80
|
if (!logs.has(hash)) {
|
|
45
81
|
logs.set(hash, logEntry)
|
|
@@ -51,6 +87,11 @@ const logCollector = {
|
|
|
51
87
|
return false
|
|
52
88
|
},
|
|
53
89
|
|
|
90
|
+
// Used for testing
|
|
91
|
+
hasEntry (logEntry) {
|
|
92
|
+
return logs.has(createHash(logEntry))
|
|
93
|
+
},
|
|
94
|
+
|
|
54
95
|
drain () {
|
|
55
96
|
if (logs.size === 0) return
|
|
56
97
|
|