dd-trace 6.0.0-pre-803ac98 → 6.0.0-pre-0d49ecf
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/package.json +1 -1
- package/packages/datadog-instrumentations/src/helpers/hooks.js +3 -0
- package/packages/datadog-instrumentations/src/jest.js +2 -2
- package/packages/datadog-instrumentations/src/node-serialize.js +22 -0
- package/packages/datadog-instrumentations/src/vitest.js +25 -12
- package/packages/datadog-instrumentations/src/vm.js +49 -0
- package/packages/datadog-plugin-http/src/client.js +5 -33
- package/packages/dd-trace/src/appsec/iast/analyzers/analyzers.js +1 -0
- package/packages/dd-trace/src/appsec/iast/analyzers/code-injection-analyzer.js +2 -0
- package/packages/dd-trace/src/appsec/iast/analyzers/untrusted-deserialization-analyzer.js +16 -0
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-handler.js +9 -8
- package/packages/dd-trace/src/appsec/iast/vulnerabilities.js +1 -0
- package/packages/dd-trace/src/appsec/waf/waf_context_wrapper.js +37 -0
- package/packages/dd-trace/src/ci-visibility/test-api-manual/test-api-manual-plugin.js +20 -3
- package/packages/dd-trace/src/debugger/devtools_client/index.js +2 -3
- package/packages/dd-trace/src/debugger/devtools_client/send.js +2 -8
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/redaction.js +0 -7
- package/packages/dd-trace/src/debugger/devtools_client/status.js +1 -1
- package/packages/dd-trace/src/llmobs/writers/spans/agentProxy.js +3 -3
- package/packages/dd-trace/src/plugins/ci_plugin.js +6 -2
- package/packages/dd-trace/src/plugins/util/test.js +4 -6
- package/packages/dd-trace/src/proxy.js +4 -1
package/package.json
CHANGED
|
@@ -88,6 +88,7 @@ module.exports = {
|
|
|
88
88
|
mysql2: () => require('../mysql2'),
|
|
89
89
|
net: () => require('../net'),
|
|
90
90
|
next: () => require('../next'),
|
|
91
|
+
'node-serialize': () => require('../node-serialize'),
|
|
91
92
|
'node:child_process': () => require('../child_process'),
|
|
92
93
|
'node:crypto': () => require('../crypto'),
|
|
93
94
|
'node:dns': () => require('../dns'),
|
|
@@ -96,6 +97,7 @@ module.exports = {
|
|
|
96
97
|
'node:https': () => require('../http'),
|
|
97
98
|
'node:net': () => require('../net'),
|
|
98
99
|
'node:url': () => require('../url'),
|
|
100
|
+
'node:vm': () => require('../vm'),
|
|
99
101
|
nyc: () => require('../nyc'),
|
|
100
102
|
oracledb: () => require('../oracledb'),
|
|
101
103
|
openai: () => require('../openai'),
|
|
@@ -122,6 +124,7 @@ module.exports = {
|
|
|
122
124
|
undici: () => require('../undici'),
|
|
123
125
|
url: () => require('../url'),
|
|
124
126
|
vitest: { esmFirst: true, fn: () => require('../vitest') },
|
|
127
|
+
vm: () => require('../vm'),
|
|
125
128
|
when: () => require('../when'),
|
|
126
129
|
winston: () => require('../winston'),
|
|
127
130
|
workerpool: () => require('../mocha')
|
|
@@ -303,7 +303,7 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
|
|
|
303
303
|
const numRetries = this.global[RETRY_TIMES]
|
|
304
304
|
const numTestExecutions = event.test?.invocations
|
|
305
305
|
const willBeRetried = numRetries > 0 && numTestExecutions - 1 < numRetries
|
|
306
|
-
const mightHitBreakpoint = this.isDiEnabled && numTestExecutions >=
|
|
306
|
+
const mightHitBreakpoint = this.isDiEnabled && numTestExecutions >= 2
|
|
307
307
|
|
|
308
308
|
const asyncResource = asyncResources.get(event.test)
|
|
309
309
|
|
|
@@ -319,7 +319,7 @@ function getWrappedEnvironment (BaseEnvironment, jestVersion) {
|
|
|
319
319
|
|
|
320
320
|
// After finishing it might take a bit for the snapshot to be handled.
|
|
321
321
|
// This means that tests retried with DI are BREAKPOINT_HIT_GRACE_PERIOD_MS slower at least.
|
|
322
|
-
if (mightHitBreakpoint) {
|
|
322
|
+
if (status === 'fail' && mightHitBreakpoint) {
|
|
323
323
|
await new Promise(resolve => {
|
|
324
324
|
setTimeout(() => {
|
|
325
325
|
resolve()
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const shimmer = require('../../datadog-shimmer')
|
|
4
|
+
const { channel, addHook } = require('./helpers/instrument')
|
|
5
|
+
|
|
6
|
+
const nodeUnserializeCh = channel('datadog:node-serialize:unserialize:start')
|
|
7
|
+
|
|
8
|
+
function wrapUnserialize (serialize) {
|
|
9
|
+
return function wrappedUnserialize (obj) {
|
|
10
|
+
if (nodeUnserializeCh.hasSubscribers) {
|
|
11
|
+
nodeUnserializeCh.publish({ obj })
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return serialize.apply(this, arguments)
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
addHook({ name: 'node-serialize', versions: ['0.0.4'] }, serialize => {
|
|
19
|
+
shimmer.wrap(serialize, 'unserialize', wrapUnserialize)
|
|
20
|
+
|
|
21
|
+
return serialize
|
|
22
|
+
})
|
|
@@ -179,7 +179,9 @@ function getSortWrapper (sort) {
|
|
|
179
179
|
const knownTestsResponse = await getChannelPromise(knownTestsCh)
|
|
180
180
|
if (!knownTestsResponse.err) {
|
|
181
181
|
knownTests = knownTestsResponse.knownTests
|
|
182
|
-
const
|
|
182
|
+
const getFilePaths = this.ctx.getTestFilepaths || this.ctx._globTestFilepaths
|
|
183
|
+
|
|
184
|
+
const testFilepaths = await getFilePaths.call(this.ctx)
|
|
183
185
|
|
|
184
186
|
isEarlyFlakeDetectionFaultyCh.publish({
|
|
185
187
|
knownTests: knownTests.vitest || {},
|
|
@@ -492,15 +494,6 @@ addHook({
|
|
|
492
494
|
return vitestPackage
|
|
493
495
|
})
|
|
494
496
|
|
|
495
|
-
addHook({
|
|
496
|
-
name: 'vitest',
|
|
497
|
-
versions: ['>=2.1.0'],
|
|
498
|
-
filePattern: 'dist/chunks/RandomSequencer.*'
|
|
499
|
-
}, (randomSequencerPackage) => {
|
|
500
|
-
shimmer.wrap(randomSequencerPackage.B.prototype, 'sort', getSortWrapper)
|
|
501
|
-
return randomSequencerPackage
|
|
502
|
-
})
|
|
503
|
-
|
|
504
497
|
addHook({
|
|
505
498
|
name: 'vitest',
|
|
506
499
|
versions: ['>=2.0.5 <2.1.0'],
|
|
@@ -513,6 +506,24 @@ addHook({
|
|
|
513
506
|
return vitestPackage
|
|
514
507
|
})
|
|
515
508
|
|
|
509
|
+
addHook({
|
|
510
|
+
name: 'vitest',
|
|
511
|
+
versions: ['>=2.1.0 <3.0.0'],
|
|
512
|
+
filePattern: 'dist/chunks/RandomSequencer.*'
|
|
513
|
+
}, (randomSequencerPackage) => {
|
|
514
|
+
shimmer.wrap(randomSequencerPackage.B.prototype, 'sort', getSortWrapper)
|
|
515
|
+
return randomSequencerPackage
|
|
516
|
+
})
|
|
517
|
+
|
|
518
|
+
addHook({
|
|
519
|
+
name: 'vitest',
|
|
520
|
+
versions: ['>=3.0.0'],
|
|
521
|
+
filePattern: 'dist/chunks/resolveConfig.*'
|
|
522
|
+
}, (randomSequencerPackage) => {
|
|
523
|
+
shimmer.wrap(randomSequencerPackage.B.prototype, 'sort', getSortWrapper)
|
|
524
|
+
return randomSequencerPackage
|
|
525
|
+
})
|
|
526
|
+
|
|
516
527
|
// Can't specify file because compiled vitest includes hashes in their files
|
|
517
528
|
addHook({
|
|
518
529
|
name: 'vitest',
|
|
@@ -533,15 +544,17 @@ addHook({
|
|
|
533
544
|
versions: ['>=1.6.0'],
|
|
534
545
|
file: 'dist/index.js'
|
|
535
546
|
}, (vitestPackage, frameworkVersion) => {
|
|
536
|
-
shimmer.wrap(vitestPackage, 'startTests', startTests => async function (
|
|
547
|
+
shimmer.wrap(vitestPackage, 'startTests', startTests => async function (testPaths) {
|
|
537
548
|
let testSuiteError = null
|
|
538
549
|
if (!testSuiteStartCh.hasSubscribers) {
|
|
539
550
|
return startTests.apply(this, arguments)
|
|
540
551
|
}
|
|
552
|
+
// From >=3.0.1, the first arguments changes from a string to an object containing the filepath
|
|
553
|
+
const testSuiteAbsolutePath = testPaths[0]?.filepath || testPaths[0]
|
|
541
554
|
|
|
542
555
|
const testSuiteAsyncResource = new AsyncResource('bound-anonymous-fn')
|
|
543
556
|
testSuiteAsyncResource.runInAsyncScope(() => {
|
|
544
|
-
testSuiteStartCh.publish({ testSuiteAbsolutePath
|
|
557
|
+
testSuiteStartCh.publish({ testSuiteAbsolutePath, frameworkVersion })
|
|
545
558
|
})
|
|
546
559
|
const startTestsResponse = await startTests.apply(this, arguments)
|
|
547
560
|
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const { channel, addHook } = require('./helpers/instrument')
|
|
4
|
+
const shimmer = require('../../datadog-shimmer')
|
|
5
|
+
const names = ['vm', 'node:vm']
|
|
6
|
+
|
|
7
|
+
const runScriptStartChannel = channel('datadog:vm:run-script:start')
|
|
8
|
+
const sourceTextModuleStartChannel = channel('datadog:vm:source-text-module:start')
|
|
9
|
+
|
|
10
|
+
addHook({ name: names }, function (vm) {
|
|
11
|
+
vm.Script = class extends vm.Script {
|
|
12
|
+
constructor (code) {
|
|
13
|
+
super(...arguments)
|
|
14
|
+
|
|
15
|
+
if (runScriptStartChannel.hasSubscribers && code) {
|
|
16
|
+
runScriptStartChannel.publish({ code })
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (vm.SourceTextModule && typeof vm.SourceTextModule === 'function') {
|
|
22
|
+
vm.SourceTextModule = class extends vm.SourceTextModule {
|
|
23
|
+
constructor (code) {
|
|
24
|
+
super(...arguments)
|
|
25
|
+
|
|
26
|
+
if (sourceTextModuleStartChannel.hasSubscribers && code) {
|
|
27
|
+
sourceTextModuleStartChannel.publish({ code })
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
shimmer.wrap(vm, 'runInContext', wrapVMMethod)
|
|
34
|
+
shimmer.wrap(vm, 'runInNewContext', wrapVMMethod)
|
|
35
|
+
shimmer.wrap(vm, 'runInThisContext', wrapVMMethod)
|
|
36
|
+
shimmer.wrap(vm, 'compileFunction', wrapVMMethod)
|
|
37
|
+
|
|
38
|
+
return vm
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
function wrapVMMethod (original) {
|
|
42
|
+
return function wrappedVMMethod (code) {
|
|
43
|
+
if (runScriptStartChannel.hasSubscribers && code) {
|
|
44
|
+
runScriptStartChannel.publish({ code })
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return original.apply(this, arguments)
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -59,6 +59,11 @@ class HttpClientPlugin extends ClientPlugin {
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
if (this.shouldInjectTraceHeaders(options, uri)) {
|
|
62
|
+
// Clone the headers object in case an upstream lib has a reference to the original headers
|
|
63
|
+
// Implemented due to aws-sdk issue where request signing is broken if we mutate the headers
|
|
64
|
+
// Explained further in:
|
|
65
|
+
// https://github.com/open-telemetry/opentelemetry-js-contrib/issues/1609#issuecomment-1826167348
|
|
66
|
+
options.headers = Object.assign({}, options.headers)
|
|
62
67
|
this.tracer.inject(span, HTTP_HEADERS, options.headers)
|
|
63
68
|
}
|
|
64
69
|
|
|
@@ -72,10 +77,6 @@ class HttpClientPlugin extends ClientPlugin {
|
|
|
72
77
|
}
|
|
73
78
|
|
|
74
79
|
shouldInjectTraceHeaders (options, uri) {
|
|
75
|
-
if (hasAmazonSignature(options) && !this.config.enablePropagationWithAmazonHeaders) {
|
|
76
|
-
return false
|
|
77
|
-
}
|
|
78
|
-
|
|
79
80
|
if (!this.config.propagationFilter(uri)) {
|
|
80
81
|
return false
|
|
81
82
|
}
|
|
@@ -212,31 +213,6 @@ function getHooks (config) {
|
|
|
212
213
|
return { request }
|
|
213
214
|
}
|
|
214
215
|
|
|
215
|
-
function hasAmazonSignature (options) {
|
|
216
|
-
if (!options) {
|
|
217
|
-
return false
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
if (options.headers) {
|
|
221
|
-
const headers = Object.keys(options.headers)
|
|
222
|
-
.reduce((prev, next) => Object.assign(prev, {
|
|
223
|
-
[next.toLowerCase()]: options.headers[next]
|
|
224
|
-
}), {})
|
|
225
|
-
|
|
226
|
-
if (headers['x-amz-signature']) {
|
|
227
|
-
return true
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
if ([].concat(headers.authorization).some(startsWith('AWS4-HMAC-SHA256'))) {
|
|
231
|
-
return true
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
const search = options.search || options.path
|
|
236
|
-
|
|
237
|
-
return search && search.toLowerCase().indexOf('x-amz-signature=') !== -1
|
|
238
|
-
}
|
|
239
|
-
|
|
240
216
|
function extractSessionDetails (options) {
|
|
241
217
|
if (typeof options === 'string') {
|
|
242
218
|
return new URL(options).host
|
|
@@ -248,8 +224,4 @@ function extractSessionDetails (options) {
|
|
|
248
224
|
return { host, port }
|
|
249
225
|
}
|
|
250
226
|
|
|
251
|
-
function startsWith (searchString) {
|
|
252
|
-
return value => String(value).startsWith(searchString)
|
|
253
|
-
}
|
|
254
|
-
|
|
255
227
|
module.exports = HttpClientPlugin
|
|
@@ -17,6 +17,7 @@ module.exports = {
|
|
|
17
17
|
SSRF: require('./ssrf-analyzer'),
|
|
18
18
|
TEMPLATE_INJECTION_ANALYZER: require('./template-injection-analyzer'),
|
|
19
19
|
UNVALIDATED_REDIRECT_ANALYZER: require('./unvalidated-redirect-analyzer'),
|
|
20
|
+
UNTRUSTED_DESERIALIZATION_ANALYZER: require('./untrusted-deserialization-analyzer'),
|
|
20
21
|
WEAK_CIPHER_ANALYZER: require('./weak-cipher-analyzer'),
|
|
21
22
|
WEAK_HASH_ANALYZER: require('./weak-hash-analyzer'),
|
|
22
23
|
WEAK_RANDOMNESS_ANALYZER: require('./weak-randomness-analyzer'),
|
|
@@ -10,6 +10,8 @@ class CodeInjectionAnalyzer extends InjectionAnalyzer {
|
|
|
10
10
|
|
|
11
11
|
onConfigure () {
|
|
12
12
|
this.addSub('datadog:eval:call', ({ script }) => this.analyze(script))
|
|
13
|
+
this.addSub('datadog:vm:run-script:start', ({ code }) => this.analyze(code))
|
|
14
|
+
this.addSub('datadog:vm:source-text-module:start', ({ code }) => this.analyze(code))
|
|
13
15
|
}
|
|
14
16
|
|
|
15
17
|
_areRangesVulnerable () {
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const InjectionAnalyzer = require('./injection-analyzer')
|
|
4
|
+
const { UNTRUSTED_DESERIALIZATION } = require('../vulnerabilities')
|
|
5
|
+
|
|
6
|
+
class UntrustedDeserializationAnalyzer extends InjectionAnalyzer {
|
|
7
|
+
constructor () {
|
|
8
|
+
super(UNTRUSTED_DESERIALIZATION)
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
onConfigure () {
|
|
12
|
+
this.addSub('datadog:node-serialize:unserialize:start', ({ obj }) => this.analyze(obj))
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
module.exports = new UntrustedDeserializationAnalyzer()
|
|
@@ -25,19 +25,20 @@ class SensitiveHandler {
|
|
|
25
25
|
|
|
26
26
|
this._sensitiveAnalyzers = new Map()
|
|
27
27
|
this._sensitiveAnalyzers.set(vulnerabilities.CODE_INJECTION, taintedRangeBasedSensitiveAnalyzer)
|
|
28
|
-
this._sensitiveAnalyzers.set(vulnerabilities.TEMPLATE_INJECTION, taintedRangeBasedSensitiveAnalyzer)
|
|
29
28
|
this._sensitiveAnalyzers.set(vulnerabilities.COMMAND_INJECTION, commandSensitiveAnalyzer)
|
|
30
|
-
this._sensitiveAnalyzers.set(vulnerabilities.
|
|
29
|
+
this._sensitiveAnalyzers.set(vulnerabilities.HARDCODED_PASSWORD, (evidence) => {
|
|
30
|
+
return hardcodedPasswordAnalyzer(evidence, this._valuePattern)
|
|
31
|
+
})
|
|
32
|
+
this._sensitiveAnalyzers.set(vulnerabilities.HEADER_INJECTION, (evidence) => {
|
|
33
|
+
return headerSensitiveAnalyzer(evidence, this._namePattern, this._valuePattern)
|
|
34
|
+
})
|
|
31
35
|
this._sensitiveAnalyzers.set(vulnerabilities.LDAP_INJECTION, ldapSensitiveAnalyzer)
|
|
36
|
+
this._sensitiveAnalyzers.set(vulnerabilities.NOSQL_MONGODB_INJECTION, jsonSensitiveAnalyzer)
|
|
32
37
|
this._sensitiveAnalyzers.set(vulnerabilities.SQL_INJECTION, sqlSensitiveAnalyzer)
|
|
33
38
|
this._sensitiveAnalyzers.set(vulnerabilities.SSRF, urlSensitiveAnalyzer)
|
|
39
|
+
this._sensitiveAnalyzers.set(vulnerabilities.TEMPLATE_INJECTION, taintedRangeBasedSensitiveAnalyzer)
|
|
40
|
+
this._sensitiveAnalyzers.set(vulnerabilities.UNTRUSTED_DESERIALIZATION, taintedRangeBasedSensitiveAnalyzer)
|
|
34
41
|
this._sensitiveAnalyzers.set(vulnerabilities.UNVALIDATED_REDIRECT, urlSensitiveAnalyzer)
|
|
35
|
-
this._sensitiveAnalyzers.set(vulnerabilities.HEADER_INJECTION, (evidence) => {
|
|
36
|
-
return headerSensitiveAnalyzer(evidence, this._namePattern, this._valuePattern)
|
|
37
|
-
})
|
|
38
|
-
this._sensitiveAnalyzers.set(vulnerabilities.HARDCODED_PASSWORD, (evidence) => {
|
|
39
|
-
return hardcodedPasswordAnalyzer(evidence, this._valuePattern)
|
|
40
|
-
})
|
|
41
42
|
}
|
|
42
43
|
|
|
43
44
|
isSensibleName (name) {
|
|
@@ -15,6 +15,7 @@ module.exports = {
|
|
|
15
15
|
SSRF: 'SSRF',
|
|
16
16
|
TEMPLATE_INJECTION: 'TEMPLATE_INJECTION',
|
|
17
17
|
UNVALIDATED_REDIRECT: 'UNVALIDATED_REDIRECT',
|
|
18
|
+
UNTRUSTED_DESERIALIZATION: 'UNTRUSTED_DESERIALIZATION',
|
|
18
19
|
WEAK_CIPHER: 'WEAK_CIPHER',
|
|
19
20
|
WEAK_HASH: 'WEAK_HASH',
|
|
20
21
|
WEAK_RANDOMNESS: 'WEAK_RANDOMNESS',
|
|
@@ -19,6 +19,7 @@ class WAFContextWrapper {
|
|
|
19
19
|
this.rulesVersion = rulesVersion
|
|
20
20
|
this.addressesToSkip = new Set()
|
|
21
21
|
this.knownAddresses = knownAddresses
|
|
22
|
+
this.cachedUserIdActions = new Map()
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
run ({ persistent, ephemeral }, raspRule) {
|
|
@@ -27,6 +28,16 @@ class WAFContextWrapper {
|
|
|
27
28
|
return
|
|
28
29
|
}
|
|
29
30
|
|
|
31
|
+
// SPECIAL CASE FOR USER_ID
|
|
32
|
+
// TODO: make this universal
|
|
33
|
+
const userId = persistent?.[addresses.USER_ID] || ephemeral?.[addresses.USER_ID]
|
|
34
|
+
if (userId) {
|
|
35
|
+
const cachedAction = this.cachedUserIdActions.get(userId)
|
|
36
|
+
if (cachedAction) {
|
|
37
|
+
return cachedAction
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
30
41
|
const payload = {}
|
|
31
42
|
let payloadHasData = false
|
|
32
43
|
const newAddressesToSkip = new Set(this.addressesToSkip)
|
|
@@ -79,6 +90,12 @@ class WAFContextWrapper {
|
|
|
79
90
|
|
|
80
91
|
const blockTriggered = !!getBlockingAction(result.actions)
|
|
81
92
|
|
|
93
|
+
// SPECIAL CASE FOR USER_ID
|
|
94
|
+
// TODO: make this universal
|
|
95
|
+
if (userId && ruleTriggered && blockTriggered) {
|
|
96
|
+
this.setUserIdCache(userId, result)
|
|
97
|
+
}
|
|
98
|
+
|
|
82
99
|
Reporter.reportMetrics({
|
|
83
100
|
duration: result.totalRuntime / 1e3,
|
|
84
101
|
durationExt: parseInt(end - start) / 1e3,
|
|
@@ -105,6 +122,26 @@ class WAFContextWrapper {
|
|
|
105
122
|
}
|
|
106
123
|
}
|
|
107
124
|
|
|
125
|
+
setUserIdCache (userId, result) {
|
|
126
|
+
// using old loops for speed
|
|
127
|
+
for (let i = 0; i < result.events.length; i++) {
|
|
128
|
+
const event = result.events[i]
|
|
129
|
+
|
|
130
|
+
for (let j = 0; j < event?.rule_matches?.length; j++) {
|
|
131
|
+
const match = event.rule_matches[j]
|
|
132
|
+
|
|
133
|
+
for (let k = 0; k < match?.parameters?.length; k++) {
|
|
134
|
+
const parameter = match.parameters[k]
|
|
135
|
+
|
|
136
|
+
if (parameter?.address === addresses.USER_ID) {
|
|
137
|
+
this.cachedUserIdActions.set(userId, result.actions)
|
|
138
|
+
return
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
108
145
|
dispose () {
|
|
109
146
|
this.ddwafContext.dispose()
|
|
110
147
|
}
|
|
@@ -13,15 +13,16 @@ class TestApiManualPlugin extends CiPlugin {
|
|
|
13
13
|
|
|
14
14
|
constructor (...args) {
|
|
15
15
|
super(...args)
|
|
16
|
+
this._isEnvDataCalcualted = false
|
|
16
17
|
this.sourceRoot = process.cwd()
|
|
17
18
|
|
|
18
|
-
this.
|
|
19
|
+
this.unconfiguredAddSub('dd-trace:ci:manual:test:start', ({ testName, testSuite }) => {
|
|
19
20
|
const store = storage.getStore()
|
|
20
21
|
const testSuiteRelative = getTestSuitePath(testSuite, this.sourceRoot)
|
|
21
22
|
const testSpan = this.startTestSpan(testName, testSuiteRelative)
|
|
22
23
|
this.enter(testSpan, store)
|
|
23
24
|
})
|
|
24
|
-
this.
|
|
25
|
+
this.unconfiguredAddSub('dd-trace:ci:manual:test:finish', ({ status, error }) => {
|
|
25
26
|
const store = storage.getStore()
|
|
26
27
|
const testSpan = store && store.span
|
|
27
28
|
if (testSpan) {
|
|
@@ -33,7 +34,7 @@ class TestApiManualPlugin extends CiPlugin {
|
|
|
33
34
|
finishAllTraceSpans(testSpan)
|
|
34
35
|
}
|
|
35
36
|
})
|
|
36
|
-
this.
|
|
37
|
+
this.unconfiguredAddSub('dd-trace:ci:manual:test:addTags', (tags) => {
|
|
37
38
|
const store = storage.getStore()
|
|
38
39
|
const testSpan = store && store.span
|
|
39
40
|
if (testSpan) {
|
|
@@ -41,6 +42,22 @@ class TestApiManualPlugin extends CiPlugin {
|
|
|
41
42
|
}
|
|
42
43
|
})
|
|
43
44
|
}
|
|
45
|
+
|
|
46
|
+
// To lazily calculate env data.
|
|
47
|
+
unconfiguredAddSub (channelName, handler) {
|
|
48
|
+
this.addSub(channelName, (...args) => {
|
|
49
|
+
if (!this._isEnvDataCalcualted) {
|
|
50
|
+
this._isEnvDataCalcualted = true
|
|
51
|
+
this.configure(this._config, true)
|
|
52
|
+
}
|
|
53
|
+
return handler(...args)
|
|
54
|
+
})
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
configure (config, shouldGetEnvironmentData) {
|
|
58
|
+
this._config = config
|
|
59
|
+
super.configure(config, shouldGetEnvironmentData)
|
|
60
|
+
}
|
|
44
61
|
}
|
|
45
62
|
|
|
46
63
|
module.exports = TestApiManualPlugin
|
|
@@ -146,10 +146,9 @@ session.on('Debugger.paused', async ({ params }) => {
|
|
|
146
146
|
}
|
|
147
147
|
}
|
|
148
148
|
|
|
149
|
+
ackEmitting(probe)
|
|
149
150
|
// TODO: Process template (DEBUG-2628)
|
|
150
|
-
send(probe.template, logger, dd, snapshot
|
|
151
|
-
ackEmitting(probe)
|
|
152
|
-
})
|
|
151
|
+
send(probe.template, logger, dd, snapshot)
|
|
153
152
|
}
|
|
154
153
|
})
|
|
155
154
|
|
|
@@ -29,10 +29,9 @@ const ddtags = [
|
|
|
29
29
|
|
|
30
30
|
const path = `/debugger/v1/input?${stringify({ ddtags })}`
|
|
31
31
|
|
|
32
|
-
let callbacks = []
|
|
33
32
|
const jsonBuffer = new JSONBuffer({ size: config.maxTotalPayloadSize, timeout: 1000, onFlush })
|
|
34
33
|
|
|
35
|
-
function send (message, logger, dd, snapshot
|
|
34
|
+
function send (message, logger, dd, snapshot) {
|
|
36
35
|
const payload = {
|
|
37
36
|
ddsource,
|
|
38
37
|
hostname,
|
|
@@ -58,7 +57,6 @@ function send (message, logger, dd, snapshot, cb) {
|
|
|
58
57
|
}
|
|
59
58
|
|
|
60
59
|
jsonBuffer.write(json, size)
|
|
61
|
-
callbacks.push(cb)
|
|
62
60
|
}
|
|
63
61
|
|
|
64
62
|
function onFlush (payload) {
|
|
@@ -69,11 +67,7 @@ function onFlush (payload) {
|
|
|
69
67
|
headers: { 'Content-Type': 'application/json; charset=utf-8' }
|
|
70
68
|
}
|
|
71
69
|
|
|
72
|
-
const _callbacks = callbacks
|
|
73
|
-
callbacks = []
|
|
74
|
-
|
|
75
70
|
request(payload, opts, (err) => {
|
|
76
|
-
if (err) log.error('
|
|
77
|
-
else _callbacks.forEach(cb => cb())
|
|
71
|
+
if (err) log.error('[debugger:devtools_client] Error sending probe payload', err)
|
|
78
72
|
})
|
|
79
73
|
}
|
|
@@ -13,7 +13,6 @@ const REDACTED_IDENTIFIERS = new Set(
|
|
|
13
13
|
'_session',
|
|
14
14
|
'_xsrf',
|
|
15
15
|
'access_token',
|
|
16
|
-
'address',
|
|
17
16
|
'aiohttp_session',
|
|
18
17
|
'api_key',
|
|
19
18
|
'apisecret',
|
|
@@ -28,7 +27,6 @@ const REDACTED_IDENTIFIERS = new Set(
|
|
|
28
27
|
'cipher',
|
|
29
28
|
'client_secret',
|
|
30
29
|
'clientid',
|
|
31
|
-
'config',
|
|
32
30
|
'connect.sid',
|
|
33
31
|
'connectionstring',
|
|
34
32
|
'cookie',
|
|
@@ -39,10 +37,8 @@ const REDACTED_IDENTIFIERS = new Set(
|
|
|
39
37
|
'cvv',
|
|
40
38
|
'databaseurl',
|
|
41
39
|
'db_url',
|
|
42
|
-
'email',
|
|
43
40
|
'encryption_key',
|
|
44
41
|
'encryptionkeyid',
|
|
45
|
-
'env',
|
|
46
42
|
'geo_location',
|
|
47
43
|
'gpg_key',
|
|
48
44
|
'ip_address',
|
|
@@ -62,7 +58,6 @@ const REDACTED_IDENTIFIERS = new Set(
|
|
|
62
58
|
'pem_file',
|
|
63
59
|
'pgp_key',
|
|
64
60
|
'PHPSESSID',
|
|
65
|
-
'phonenumber',
|
|
66
61
|
'pin',
|
|
67
62
|
'pincode',
|
|
68
63
|
'pkcs8',
|
|
@@ -71,7 +66,6 @@ const REDACTED_IDENTIFIERS = new Set(
|
|
|
71
66
|
'pwd',
|
|
72
67
|
'recaptcha_key',
|
|
73
68
|
'refresh_token',
|
|
74
|
-
'remote_addr',
|
|
75
69
|
'routingnumber',
|
|
76
70
|
'salt',
|
|
77
71
|
'secret',
|
|
@@ -94,7 +88,6 @@ const REDACTED_IDENTIFIERS = new Set(
|
|
|
94
88
|
'transactionid',
|
|
95
89
|
'twilio_token',
|
|
96
90
|
'user_session',
|
|
97
|
-
'uuid',
|
|
98
91
|
'voterid',
|
|
99
92
|
'x-auth-token',
|
|
100
93
|
'x_api_key',
|
|
@@ -94,7 +94,7 @@ function onFlush (payload) {
|
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
request(form, options, (err) => {
|
|
97
|
-
if (err) log.error('[debugger:devtools_client] Error sending
|
|
97
|
+
if (err) log.error('[debugger:devtools_client] Error sending diagnostics payload', err)
|
|
98
98
|
})
|
|
99
99
|
}
|
|
100
100
|
|
|
@@ -10,10 +10,10 @@ const LLMObsBaseSpanWriter = require('./base')
|
|
|
10
10
|
class LLMObsAgentProxySpanWriter extends LLMObsBaseSpanWriter {
|
|
11
11
|
constructor (config) {
|
|
12
12
|
super({
|
|
13
|
-
intake: config.hostname || 'localhost',
|
|
14
|
-
protocol: 'http:',
|
|
13
|
+
intake: config.url?.hostname || config.hostname || 'localhost',
|
|
14
|
+
protocol: config.url?.protocol || 'http:',
|
|
15
15
|
endpoint: EVP_PROXY_AGENT_ENDPOINT,
|
|
16
|
-
port: config.port
|
|
16
|
+
port: config.url?.port || config.port
|
|
17
17
|
})
|
|
18
18
|
|
|
19
19
|
this._headers[EVP_SUBDOMAIN_HEADER_NAME] = EVP_SUBDOMAIN_HEADER_VALUE
|
|
@@ -184,14 +184,18 @@ module.exports = class CiPlugin extends Plugin {
|
|
|
184
184
|
}
|
|
185
185
|
}
|
|
186
186
|
|
|
187
|
-
configure (config) {
|
|
187
|
+
configure (config, shouldGetEnvironmentData = true) {
|
|
188
188
|
super.configure(config)
|
|
189
189
|
|
|
190
|
-
if (config.isTestDynamicInstrumentationEnabled) {
|
|
190
|
+
if (config.isTestDynamicInstrumentationEnabled && !this.di) {
|
|
191
191
|
const testVisibilityDynamicInstrumentation = require('../ci-visibility/dynamic-instrumentation')
|
|
192
192
|
this.di = testVisibilityDynamicInstrumentation
|
|
193
193
|
}
|
|
194
194
|
|
|
195
|
+
if (!shouldGetEnvironmentData) {
|
|
196
|
+
return
|
|
197
|
+
}
|
|
198
|
+
|
|
195
199
|
this.testEnvironmentMetadata = getTestEnvironmentMetadata(this.constructor.id, this.config)
|
|
196
200
|
|
|
197
201
|
const {
|
|
@@ -691,14 +691,12 @@ function getFileAndLineNumberFromError (error, repositoryRoot) {
|
|
|
691
691
|
return []
|
|
692
692
|
}
|
|
693
693
|
|
|
694
|
-
// The error.stack property in TestingLibraryElementError includes the message, which results in redundant information
|
|
695
694
|
function getFormattedError (error, repositoryRoot) {
|
|
696
|
-
if (error.name !== 'TestingLibraryElementError') {
|
|
697
|
-
return error
|
|
698
|
-
}
|
|
699
|
-
const { stack } = error
|
|
700
695
|
const newError = new Error(error.message)
|
|
701
|
-
|
|
696
|
+
if (error.stack) {
|
|
697
|
+
newError.stack = error.stack.split('\n').filter(line => line.includes(repositoryRoot)).join('\n')
|
|
698
|
+
}
|
|
699
|
+
newError.name = error.name
|
|
702
700
|
|
|
703
701
|
return newError
|
|
704
702
|
}
|
|
@@ -166,7 +166,10 @@ class Tracer extends NoopProxy {
|
|
|
166
166
|
if (config.isManualApiEnabled) {
|
|
167
167
|
const TestApiManualPlugin = require('./ci-visibility/test-api-manual/test-api-manual-plugin')
|
|
168
168
|
this._testApiManualPlugin = new TestApiManualPlugin(this)
|
|
169
|
-
|
|
169
|
+
// `shouldGetEnvironmentData` is passed as false so that we only lazily calculate it
|
|
170
|
+
// This is the only place where we need to do this because the rest of the plugins
|
|
171
|
+
// are lazily configured when the library is imported.
|
|
172
|
+
this._testApiManualPlugin.configure({ ...config, enabled: true }, false)
|
|
170
173
|
}
|
|
171
174
|
}
|
|
172
175
|
if (config.ciVisAgentlessLogSubmissionEnabled) {
|