dd-trace 3.14.0 → 3.15.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/LICENSE-3rdparty.csv +1 -0
- package/README.md +5 -5
- package/index.d.ts +30 -1
- package/package.json +5 -4
- package/packages/datadog-instrumentations/src/ldapjs.js +12 -2
- package/packages/datadog-instrumentations/src/mongoose.js +1 -1
- package/packages/datadog-instrumentations/src/next.js +2 -1
- package/packages/datadog-instrumentations/src/playwright.js +40 -11
- package/packages/datadog-plugin-hapi/src/index.js +5 -1
- package/packages/datadog-plugin-http/src/server.js +1 -1
- package/packages/datadog-plugin-http2/src/server.js +1 -1
- package/packages/dd-trace/src/appsec/addresses.js +3 -1
- package/packages/dd-trace/src/appsec/blocking.js +35 -9
- package/packages/dd-trace/src/appsec/iast/iast-context.js +6 -2
- package/packages/dd-trace/src/appsec/iast/index.js +3 -2
- package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter.js +5 -2
- package/packages/dd-trace/src/appsec/index.js +4 -4
- package/packages/dd-trace/src/appsec/recommended.json +76 -75
- package/packages/dd-trace/src/appsec/remote_config/capabilities.js +2 -1
- package/packages/dd-trace/src/appsec/remote_config/index.js +3 -0
- package/packages/dd-trace/src/appsec/sdk/index.js +19 -1
- package/packages/dd-trace/src/appsec/sdk/noop.js +6 -0
- package/packages/dd-trace/src/appsec/sdk/set_user.js +30 -0
- package/packages/dd-trace/src/appsec/sdk/track_event.js +2 -2
- package/packages/dd-trace/src/appsec/sdk/user_blocking.js +73 -0
- package/packages/dd-trace/src/ci-visibility/exporters/ci-visibility-exporter.js +15 -0
- package/packages/dd-trace/src/ci-visibility/exporters/git/git_metadata.js +7 -1
- package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-itr-configuration.js +4 -2
- package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +4 -2
- package/packages/dd-trace/src/config.js +1 -1
- package/packages/dd-trace/src/lambda/handler.js +5 -6
- package/packages/dd-trace/src/log/writer.js +32 -24
- package/packages/dd-trace/src/metrics.js +18 -0
- package/packages/dd-trace/src/noop/proxy.js +2 -2
- package/packages/dd-trace/src/opentracing/propagation/text_map.js +2 -0
- package/packages/dd-trace/src/opentracing/span_context.js +5 -3
- package/packages/dd-trace/src/plugins/ci_plugin.js +4 -1
- package/packages/dd-trace/src/plugins/util/exec.js +2 -2
- package/packages/dd-trace/src/plugins/util/git.js +16 -1
- package/packages/dd-trace/src/profiler.js +3 -0
- package/packages/dd-trace/src/profiling/config.js +8 -3
- package/packages/dd-trace/src/profiling/exporters/file.js +13 -2
- package/packages/dd-trace/src/profiling/profiler.js +23 -6
- package/packages/dd-trace/src/profiling/profilers/wall.js +1 -0
- package/packages/dd-trace/src/proxy.js +1 -1
- package/packages/dd-trace/src/span_processor.js +1 -1
- package/packages/dd-trace/src/span_sampler.js +68 -52
- package/packages/dd-trace/src/startup-log.js +3 -6
- package/packages/dd-trace/src/tracer.js +0 -16
package/LICENSE-3rdparty.csv
CHANGED
|
@@ -57,6 +57,7 @@ dev,multer,MIT,Copyright 2014 Hage Yaapa
|
|
|
57
57
|
dev,msgpack-lite,MIT,Copyright 2015 Yusuke Kawasaki
|
|
58
58
|
dev,nock,MIT,Copyright 2017 Pedro Teixeira and other contributors
|
|
59
59
|
dev,nyc,ISC,Copyright 2015 Contributors
|
|
60
|
+
dev,pprof-format,MIT,Copyright 2022 Stephen Belanger
|
|
60
61
|
dev,proxyquire,MIT,Copyright 2013 Thorsten Lorenz
|
|
61
62
|
dev,rimraf,ISC,Copyright Isaac Z. Schlueter and Contributors
|
|
62
63
|
dev,sinon,BSD-3-Clause,Copyright 2010-2017 Christian Johansen
|
package/README.md
CHANGED
|
@@ -24,11 +24,11 @@ Most of the documentation for `dd-trace` is available on these webpages:
|
|
|
24
24
|
|
|
25
25
|
## Version Release Lines and Maintenance
|
|
26
26
|
|
|
27
|
-
| Release Line | Latest Version | Status |Initial Release | End of Life |
|
|
28
|
-
|
|
|
29
|
-
| [`v1`](https://github.com/DataDog/dd-trace-js/tree/v1.x) |  | **End of Life** | 2021-07-13 | 2022-02-25 |
|
|
30
|
-
| [`v2`](https://github.com/DataDog/dd-trace-js/tree/v2.x) |  | **Maintenance** | 2022-01-28 | 2023-08-15 |
|
|
31
|
-
| [`v3`](https://github.com/DataDog/dd-trace-js/tree/v3.x) |  | **Current** | 2022-08-15 | Unknown |
|
|
27
|
+
| Release Line | Latest Version | Node.js | Status |Initial Release | End of Life |
|
|
28
|
+
| :---: | :---: | :---: | :---: | :---: | :---: |
|
|
29
|
+
| [`v1`](https://github.com/DataDog/dd-trace-js/tree/v1.x) |  | `>= v12` | **End of Life** | 2021-07-13 | 2022-02-25 |
|
|
30
|
+
| [`v2`](https://github.com/DataDog/dd-trace-js/tree/v2.x) |  | `>= v12` | **Maintenance** | 2022-01-28 | 2023-08-15 |
|
|
31
|
+
| [`v3`](https://github.com/DataDog/dd-trace-js/tree/v3.x) |  | `>= v14` | **Current** | 2022-08-15 | Unknown |
|
|
32
32
|
|
|
33
33
|
We currently maintain two release lines, namely `v2` and `v3`.
|
|
34
34
|
Features and bug fixes that are merged are released to the `v3` line and, if appropriate, also the `v2` line.
|
package/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ClientRequest, IncomingMessage, ServerResponse } from "http";
|
|
1
|
+
import { ClientRequest, IncomingMessage, OutgoingMessage, ServerResponse } from "http";
|
|
2
2
|
import { LookupFunction } from 'net';
|
|
3
3
|
import * as opentracing from "opentracing";
|
|
4
4
|
import { SpanOptions } from "opentracing/lib/tracer";
|
|
@@ -643,6 +643,35 @@ export declare interface Appsec {
|
|
|
643
643
|
* @beta This method is in beta and could change in future versions.
|
|
644
644
|
*/
|
|
645
645
|
trackCustomEvent(eventName: string, metadata?: { [key: string]: string }): void
|
|
646
|
+
|
|
647
|
+
/**
|
|
648
|
+
* Checks if the passed user should be blocked according to AppSec rules.
|
|
649
|
+
* If no user is linked to the current trace, will link the passed user to it.
|
|
650
|
+
* @param {User} user Properties of the authenticated user. Accepts custom fields.
|
|
651
|
+
* @return {boolean} Indicates whether the user should be blocked.
|
|
652
|
+
*
|
|
653
|
+
* @beta This method is in beta and could change in the future
|
|
654
|
+
*/
|
|
655
|
+
isUserBlocked(user: User): boolean
|
|
656
|
+
|
|
657
|
+
/**
|
|
658
|
+
* Sends a "blocked" template response based on the request accept header and ends the response.
|
|
659
|
+
* **You should stop processing the request after calling this function!**
|
|
660
|
+
* @param {IncomingMessage} req Can be passed to force which request to act on. Optional.
|
|
661
|
+
* @param {OutgoingMessage} res Can be passed to force which response to act on. Optional.
|
|
662
|
+
* @return {boolean} Indicates if the action was successful.
|
|
663
|
+
*
|
|
664
|
+
* @beta This method is in beta and could change in the future
|
|
665
|
+
*/
|
|
666
|
+
blockRequest(req?: IncomingMessage, res?: OutgoingMessage): boolean
|
|
667
|
+
|
|
668
|
+
/**
|
|
669
|
+
* Links an authenticated user to the current trace.
|
|
670
|
+
* @param {User} user Properties of the authenticated user. Accepts custom fields.
|
|
671
|
+
*
|
|
672
|
+
* @beta This method is in beta and could change in the future
|
|
673
|
+
*/
|
|
674
|
+
setUser(user: User): void
|
|
646
675
|
}
|
|
647
676
|
|
|
648
677
|
/** @hidden */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dd-trace",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.15.0",
|
|
4
4
|
"description": "Datadog APM tracing client for JavaScript",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"typings": "index.d.ts",
|
|
@@ -61,10 +61,10 @@
|
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
63
|
"@datadog/native-appsec": "2.0.0",
|
|
64
|
-
"@datadog/native-iast-rewriter": "
|
|
65
|
-
"@datadog/native-iast-taint-tracking": "1.1.
|
|
64
|
+
"@datadog/native-iast-rewriter": "2.0.1",
|
|
65
|
+
"@datadog/native-iast-taint-tracking": "1.1.1",
|
|
66
66
|
"@datadog/native-metrics": "^1.5.0",
|
|
67
|
-
"@datadog/pprof": "^
|
|
67
|
+
"@datadog/pprof": "^2.0.0",
|
|
68
68
|
"@datadog/sketches-js": "^2.1.0",
|
|
69
69
|
"crypto-randomuuid": "^1.0.0",
|
|
70
70
|
"diagnostics_channel": "^1.1.0",
|
|
@@ -120,6 +120,7 @@
|
|
|
120
120
|
"multer": "^1.4.5-lts.1",
|
|
121
121
|
"nock": "^11.3.3",
|
|
122
122
|
"nyc": "^15.1.0",
|
|
123
|
+
"pprof-format": "^2.0.7",
|
|
123
124
|
"proxyquire": "^1.8.0",
|
|
124
125
|
"rimraf": "^3.0.0",
|
|
125
126
|
"sinon": "^11.1.2",
|
|
@@ -35,7 +35,7 @@ function wrapEmitter (corkedEmitter) {
|
|
|
35
35
|
}
|
|
36
36
|
arguments[1] = bindedFn
|
|
37
37
|
}
|
|
38
|
-
on.apply(this, arguments)
|
|
38
|
+
return on.apply(this, arguments)
|
|
39
39
|
}
|
|
40
40
|
shimmer.wrap(corkedEmitter, 'on', addListener)
|
|
41
41
|
shimmer.wrap(corkedEmitter, 'addListener', addListener)
|
|
@@ -47,7 +47,7 @@ function wrapEmitter (corkedEmitter) {
|
|
|
47
47
|
arguments[1] = emitterOn
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
|
-
off.apply(this, arguments)
|
|
50
|
+
return off.apply(this, arguments)
|
|
51
51
|
}
|
|
52
52
|
shimmer.wrap(corkedEmitter, 'off', removeListener)
|
|
53
53
|
shimmer.wrap(corkedEmitter, 'removeListener', removeListener)
|
|
@@ -87,5 +87,15 @@ addHook({ name: 'ldapjs', versions: ['>=2'] }, ldapjs => {
|
|
|
87
87
|
return _send.apply(this, arguments)
|
|
88
88
|
})
|
|
89
89
|
|
|
90
|
+
shimmer.wrap(ldapjs.Client.prototype, 'bind', bind => function (dn, password, controls, callback) {
|
|
91
|
+
if (typeof controls === 'function') {
|
|
92
|
+
arguments[2] = AsyncResource.bind(controls)
|
|
93
|
+
} else if (typeof callback === 'function') {
|
|
94
|
+
arguments[3] = AsyncResource.bind(callback)
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return bind.apply(this, arguments)
|
|
98
|
+
})
|
|
99
|
+
|
|
90
100
|
return ldapjs
|
|
91
101
|
})
|
|
@@ -19,7 +19,7 @@ function wrapAddQueue (addQueue) {
|
|
|
19
19
|
|
|
20
20
|
addHook({
|
|
21
21
|
name: 'mongoose',
|
|
22
|
-
versions: ['>=4.6.4']
|
|
22
|
+
versions: ['>=4.6.4 <7'] // TODO: Mongoose v7 compat
|
|
23
23
|
}, mongoose => {
|
|
24
24
|
if (mongoose.Promise !== global.Promise) {
|
|
25
25
|
shimmer.wrap(mongoose.Promise.prototype, 'then', wrapThen)
|
|
@@ -127,7 +127,8 @@ function finish (req, res, result, err) {
|
|
|
127
127
|
return result
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
-
|
|
130
|
+
// TODO: 13.2 support
|
|
131
|
+
addHook({ name: 'next', versions: ['>=11.1 <13.2'], file: 'dist/server/next-server.js' }, nextServer => {
|
|
131
132
|
const Server = nextServer.default
|
|
132
133
|
|
|
133
134
|
shimmer.wrap(Server.prototype, 'handleRequest', wrapHandleRequest)
|
|
@@ -25,6 +25,17 @@ const STATUS_TO_TEST_STATUS = {
|
|
|
25
25
|
|
|
26
26
|
let remainingTestsByFile = {}
|
|
27
27
|
|
|
28
|
+
function getTestsBySuiteFromTestGroups (testGroups) {
|
|
29
|
+
return testGroups.reduce((acc, { requireFile, tests }) => {
|
|
30
|
+
if (acc[requireFile]) {
|
|
31
|
+
acc[requireFile] = acc[requireFile].concat(tests)
|
|
32
|
+
} else {
|
|
33
|
+
acc[requireFile] = tests
|
|
34
|
+
}
|
|
35
|
+
return acc
|
|
36
|
+
}, {})
|
|
37
|
+
}
|
|
38
|
+
|
|
28
39
|
function getTestsBySuiteFromTestsById (testsById) {
|
|
29
40
|
const testsByTestSuite = {}
|
|
30
41
|
for (const { test } of testsById.values()) {
|
|
@@ -48,7 +59,7 @@ function getPlaywrightConfig (playwrightRunner) {
|
|
|
48
59
|
try {
|
|
49
60
|
return playwrightRunner._loader.fullConfig()
|
|
50
61
|
} catch (e) {
|
|
51
|
-
return {}
|
|
62
|
+
return playwrightRunner._config || {}
|
|
52
63
|
}
|
|
53
64
|
}
|
|
54
65
|
}
|
|
@@ -135,6 +146,13 @@ function dispatcherRunWrapper (run) {
|
|
|
135
146
|
}
|
|
136
147
|
}
|
|
137
148
|
|
|
149
|
+
function dispatcherRunWrapperNew (run) {
|
|
150
|
+
return function () {
|
|
151
|
+
remainingTestsByFile = getTestsBySuiteFromTestGroups(arguments[0])
|
|
152
|
+
return run.apply(this, arguments)
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
138
156
|
function dispatcherHook (dispatcherExport) {
|
|
139
157
|
shimmer.wrap(dispatcherExport.Dispatcher.prototype, 'run', dispatcherRunWrapper)
|
|
140
158
|
shimmer.wrap(dispatcherExport.Dispatcher.prototype, '_createWorker', createWorker => function () {
|
|
@@ -160,8 +178,8 @@ function dispatcherHook (dispatcherExport) {
|
|
|
160
178
|
return dispatcherExport
|
|
161
179
|
}
|
|
162
180
|
|
|
163
|
-
function dispatcherHookNew (dispatcherExport) {
|
|
164
|
-
shimmer.wrap(dispatcherExport.Dispatcher.prototype, 'run',
|
|
181
|
+
function dispatcherHookNew (dispatcherExport, runWrapper) {
|
|
182
|
+
shimmer.wrap(dispatcherExport.Dispatcher.prototype, 'run', runWrapper)
|
|
165
183
|
shimmer.wrap(dispatcherExport.Dispatcher.prototype, '_createWorker', createWorker => function () {
|
|
166
184
|
const dispatcher = this
|
|
167
185
|
const worker = createWorker.apply(this, arguments)
|
|
@@ -192,24 +210,23 @@ function runnerHook (runnerExport, playwrightVersion) {
|
|
|
192
210
|
testSessionStartCh.publish({ command, frameworkVersion: playwrightVersion, rootDir })
|
|
193
211
|
})
|
|
194
212
|
|
|
195
|
-
const
|
|
196
|
-
const sessionStatus =
|
|
213
|
+
const runAllTestsReturn = await runAllTests.apply(this, arguments)
|
|
214
|
+
const sessionStatus = runAllTestsReturn.status || runAllTestsReturn
|
|
197
215
|
|
|
198
216
|
let onDone
|
|
199
217
|
|
|
200
218
|
const flushWait = new Promise(resolve => {
|
|
201
219
|
onDone = resolve
|
|
202
220
|
})
|
|
203
|
-
|
|
204
221
|
testSessionAsyncResource.runInAsyncScope(() => {
|
|
205
|
-
testSessionFinishCh.publish({ status: sessionStatus, onDone })
|
|
222
|
+
testSessionFinishCh.publish({ status: STATUS_TO_TEST_STATUS[sessionStatus], onDone })
|
|
206
223
|
})
|
|
207
224
|
await flushWait
|
|
208
225
|
|
|
209
226
|
startedSuites = []
|
|
210
227
|
remainingTestsByFile = {}
|
|
211
228
|
|
|
212
|
-
return
|
|
229
|
+
return runAllTestsReturn
|
|
213
230
|
})
|
|
214
231
|
|
|
215
232
|
return runnerExport
|
|
@@ -218,7 +235,7 @@ function runnerHook (runnerExport, playwrightVersion) {
|
|
|
218
235
|
addHook({
|
|
219
236
|
name: '@playwright/test',
|
|
220
237
|
file: 'lib/runner.js',
|
|
221
|
-
versions: ['>=1.18.0']
|
|
238
|
+
versions: ['>=1.18.0 <1.30.0']
|
|
222
239
|
}, runnerHook)
|
|
223
240
|
|
|
224
241
|
addHook({
|
|
@@ -230,5 +247,17 @@ addHook({
|
|
|
230
247
|
addHook({
|
|
231
248
|
name: '@playwright/test',
|
|
232
249
|
file: 'lib/dispatcher.js',
|
|
233
|
-
versions: ['>=1.30.0']
|
|
234
|
-
}, dispatcherHookNew)
|
|
250
|
+
versions: ['>=1.30.0 <1.31.0']
|
|
251
|
+
}, (dispatcher) => dispatcherHookNew(dispatcher, dispatcherRunWrapper))
|
|
252
|
+
|
|
253
|
+
addHook({
|
|
254
|
+
name: '@playwright/test',
|
|
255
|
+
file: 'lib/runner/dispatcher.js',
|
|
256
|
+
versions: ['>=1.31.0']
|
|
257
|
+
}, (dispatcher) => dispatcherHookNew(dispatcher, dispatcherRunWrapperNew))
|
|
258
|
+
|
|
259
|
+
addHook({
|
|
260
|
+
name: '@playwright/test',
|
|
261
|
+
file: 'lib/runner/runner.js',
|
|
262
|
+
versions: ['>=1.31.0']
|
|
263
|
+
}, runnerHook)
|
|
@@ -26,7 +26,11 @@ class HapiPlugin extends RouterPlugin {
|
|
|
26
26
|
web.setRoute(req, route)
|
|
27
27
|
})
|
|
28
28
|
|
|
29
|
-
this.addSub(
|
|
29
|
+
this.addSub('apm:hapi:request:error', error => {
|
|
30
|
+
if (!error || !error.isBoom || !this.config.validateStatus(error.output.statusCode)) {
|
|
31
|
+
this.addError(error)
|
|
32
|
+
}
|
|
33
|
+
})
|
|
30
34
|
|
|
31
35
|
this.addSub('apm:hapi:extension:enter', ({ req }) => {
|
|
32
36
|
this.enter(this._requestSpans.get(req))
|
|
@@ -1,8 +1,19 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
+
const log = require('../log')
|
|
3
4
|
const fs = require('fs')
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
|
|
6
|
+
// TODO: move template loading to a proper spot.
|
|
7
|
+
let templateLoaded = false
|
|
8
|
+
let templateHtml = ''
|
|
9
|
+
let templateJson = ''
|
|
10
|
+
|
|
11
|
+
function block (req, res, rootSpan, abortController) {
|
|
12
|
+
if (res.headersSent) {
|
|
13
|
+
log.warn('Cannot send blocking response when headers have already been sent')
|
|
14
|
+
return
|
|
15
|
+
}
|
|
16
|
+
|
|
6
17
|
let type
|
|
7
18
|
let body
|
|
8
19
|
|
|
@@ -17,7 +28,7 @@ function block (req, res, topSpan, abortController) {
|
|
|
17
28
|
body = templateJson
|
|
18
29
|
}
|
|
19
30
|
|
|
20
|
-
|
|
31
|
+
rootSpan.addTags({
|
|
21
32
|
'appsec.blocked': 'true'
|
|
22
33
|
})
|
|
23
34
|
|
|
@@ -26,19 +37,34 @@ function block (req, res, topSpan, abortController) {
|
|
|
26
37
|
res.setHeader('Content-Length', Buffer.byteLength(body))
|
|
27
38
|
res.end(body)
|
|
28
39
|
|
|
29
|
-
abortController
|
|
40
|
+
if (abortController) {
|
|
41
|
+
abortController.abort()
|
|
42
|
+
}
|
|
30
43
|
}
|
|
31
44
|
|
|
32
45
|
function loadTemplates (config) {
|
|
33
|
-
|
|
34
|
-
|
|
46
|
+
if (!templateLoaded) {
|
|
47
|
+
templateHtml = fs.readFileSync(config.appsec.blockedTemplateHtml)
|
|
48
|
+
templateJson = fs.readFileSync(config.appsec.blockedTemplateJson)
|
|
49
|
+
templateLoaded = true
|
|
50
|
+
}
|
|
35
51
|
}
|
|
36
52
|
|
|
37
53
|
async function loadTemplatesAsync (config) {
|
|
38
|
-
|
|
39
|
-
|
|
54
|
+
if (!templateLoaded) {
|
|
55
|
+
templateHtml = await fs.promises.readFile(config.appsec.blockedTemplateHtml)
|
|
56
|
+
templateJson = await fs.promises.readFile(config.appsec.blockedTemplateJson)
|
|
57
|
+
templateLoaded = true
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function resetTemplates () {
|
|
62
|
+
templateLoaded = false
|
|
40
63
|
}
|
|
41
64
|
|
|
42
65
|
module.exports = {
|
|
43
|
-
block,
|
|
66
|
+
block,
|
|
67
|
+
loadTemplates,
|
|
68
|
+
loadTemplatesAsync,
|
|
69
|
+
resetTemplates
|
|
44
70
|
}
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
const IAST_CONTEXT_KEY = Symbol('_dd.iast.context')
|
|
2
2
|
const IAST_TRANSACTION_ID = Symbol('_dd.iast.transactionId')
|
|
3
3
|
|
|
4
|
-
function getIastContext (store) {
|
|
5
|
-
|
|
4
|
+
function getIastContext (store, topContext) {
|
|
5
|
+
let iastContext = store && store[IAST_CONTEXT_KEY]
|
|
6
|
+
if (!iastContext) {
|
|
7
|
+
iastContext = topContext && topContext[IAST_CONTEXT_KEY]
|
|
8
|
+
}
|
|
9
|
+
return iastContext
|
|
6
10
|
}
|
|
7
11
|
|
|
8
12
|
/* TODO Fix storage problem when the close event is called without
|
|
@@ -58,7 +58,8 @@ function onIncomingHttpRequestStart (data) {
|
|
|
58
58
|
function onIncomingHttpRequestEnd (data) {
|
|
59
59
|
if (data && data.req) {
|
|
60
60
|
const store = storage.getStore()
|
|
61
|
-
const
|
|
61
|
+
const topContext = web.getContext(data.req)
|
|
62
|
+
const iastContext = iastContextFunctions.getIastContext(store, topContext)
|
|
62
63
|
if (iastContext && iastContext.rootSpan) {
|
|
63
64
|
const vulnerabilities = iastContext.vulnerabilities
|
|
64
65
|
const rootSpan = iastContext.rootSpan
|
|
@@ -66,7 +67,7 @@ function onIncomingHttpRequestEnd (data) {
|
|
|
66
67
|
removeTransaction(iastContext)
|
|
67
68
|
}
|
|
68
69
|
// TODO web.getContext(data.req) is required when the request is aborted
|
|
69
|
-
if (iastContextFunctions.cleanIastContext(store,
|
|
70
|
+
if (iastContextFunctions.cleanIastContext(store, topContext, iastContext)) {
|
|
70
71
|
overheadController.releaseRequest()
|
|
71
72
|
}
|
|
72
73
|
}
|
|
@@ -40,10 +40,13 @@ function getCompileMethodFn (compileMethod) {
|
|
|
40
40
|
return function (content, filename) {
|
|
41
41
|
try {
|
|
42
42
|
if (isPrivateModule(filename) && isNotLibraryFile(filename)) {
|
|
43
|
-
|
|
43
|
+
const rewritten = rewriter.rewrite(content, filename)
|
|
44
|
+
if (rewritten && rewritten.content) {
|
|
45
|
+
return compileMethod.apply(this, [rewritten.content, filename])
|
|
46
|
+
}
|
|
44
47
|
}
|
|
45
48
|
} catch (e) {
|
|
46
|
-
log.
|
|
49
|
+
log.error(e)
|
|
47
50
|
}
|
|
48
51
|
return compileMethod.apply(this, [content, filename])
|
|
49
52
|
}
|
|
@@ -70,12 +70,12 @@ function abortEnable (err) {
|
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
function incomingHttpStartTranslator ({ req, res, abortController }) {
|
|
73
|
-
const
|
|
74
|
-
if (!
|
|
73
|
+
const rootSpan = web.root(req)
|
|
74
|
+
if (!rootSpan) return
|
|
75
75
|
|
|
76
76
|
const clientIp = extractIp(config, req)
|
|
77
77
|
|
|
78
|
-
|
|
78
|
+
rootSpan.addTags({
|
|
79
79
|
'_dd.appsec.enabled': 1,
|
|
80
80
|
'_dd.runtime_family': 'nodejs',
|
|
81
81
|
[HTTP_CLIENT_IP]: clientIp
|
|
@@ -97,7 +97,7 @@ function incomingHttpStartTranslator ({ req, res, abortController }) {
|
|
|
97
97
|
|
|
98
98
|
for (const entry of results) {
|
|
99
99
|
if (entry && entry.includes('block')) {
|
|
100
|
-
block(req, res,
|
|
100
|
+
block(req, res, rootSpan, abortController)
|
|
101
101
|
break
|
|
102
102
|
}
|
|
103
103
|
}
|