dd-trace 3.14.1 → 3.16.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 +2 -2
- package/README.md +9 -5
- package/ci/init.js +9 -1
- package/ext/exporters.d.ts +2 -1
- package/ext/exporters.js +2 -1
- package/index.d.ts +36 -3
- package/package.json +21 -19
- package/packages/datadog-instrumentations/src/cucumber.js +80 -3
- package/packages/datadog-instrumentations/src/google-cloud-pubsub.js +100 -27
- package/packages/datadog-instrumentations/src/helpers/hooks.js +1 -0
- package/packages/datadog-instrumentations/src/jest.js +35 -3
- package/packages/datadog-instrumentations/src/ldapjs.js +12 -2
- package/packages/datadog-instrumentations/src/mariadb.js +130 -11
- package/packages/datadog-instrumentations/src/mocha.js +30 -6
- package/packages/datadog-instrumentations/src/mongodb-core.js +8 -2
- package/packages/datadog-instrumentations/src/mongoose.js +1 -1
- package/packages/datadog-instrumentations/src/next.js +33 -4
- package/packages/datadog-instrumentations/src/playwright.js +42 -13
- package/packages/datadog-plugin-amqp10/src/consumer.js +1 -1
- package/packages/datadog-plugin-amqp10/src/index.js +1 -1
- package/packages/datadog-plugin-amqp10/src/producer.js +3 -2
- package/packages/datadog-plugin-amqplib/src/client.js +3 -2
- package/packages/datadog-plugin-amqplib/src/consumer.js +1 -1
- package/packages/datadog-plugin-amqplib/src/index.js +1 -1
- package/packages/datadog-plugin-amqplib/src/producer.js +3 -2
- package/packages/datadog-plugin-aws-sdk/src/base.js +7 -2
- package/packages/datadog-plugin-aws-sdk/src/index.js +1 -1
- package/packages/datadog-plugin-aws-sdk/src/services/cloudwatchlogs.js +2 -0
- package/packages/datadog-plugin-aws-sdk/src/services/dynamodb.js +2 -0
- package/packages/datadog-plugin-aws-sdk/src/services/eventbridge.js +2 -0
- package/packages/datadog-plugin-aws-sdk/src/services/kinesis.js +2 -0
- package/packages/datadog-plugin-aws-sdk/src/services/lambda.js +2 -0
- package/packages/datadog-plugin-aws-sdk/src/services/redshift.js +2 -0
- package/packages/datadog-plugin-aws-sdk/src/services/s3.js +2 -0
- package/packages/datadog-plugin-aws-sdk/src/services/sns.js +2 -0
- package/packages/datadog-plugin-aws-sdk/src/services/sqs.js +2 -0
- package/packages/datadog-plugin-bunyan/src/index.js +1 -1
- package/packages/datadog-plugin-cassandra-driver/src/index.js +3 -2
- package/packages/datadog-plugin-connect/src/index.js +1 -1
- package/packages/datadog-plugin-couchbase/src/index.js +1 -1
- package/packages/datadog-plugin-cucumber/src/index.js +33 -6
- package/packages/datadog-plugin-cypress/src/index.js +1 -1
- package/packages/datadog-plugin-cypress/src/plugin.js +40 -33
- package/packages/datadog-plugin-dns/src/index.js +1 -1
- package/packages/datadog-plugin-dns/src/lookup.js +1 -1
- package/packages/datadog-plugin-dns/src/lookup_service.js +1 -1
- package/packages/datadog-plugin-dns/src/resolve.js +1 -1
- package/packages/datadog-plugin-dns/src/reverse.js +1 -1
- package/packages/datadog-plugin-elasticsearch/src/index.js +1 -1
- package/packages/datadog-plugin-express/src/index.js +1 -1
- package/packages/datadog-plugin-fastify/src/index.js +1 -1
- package/packages/datadog-plugin-find-my-way/src/index.js +1 -1
- package/packages/datadog-plugin-fs/src/index.js +1 -1
- package/packages/datadog-plugin-google-cloud-pubsub/src/client.js +5 -5
- package/packages/datadog-plugin-google-cloud-pubsub/src/consumer.js +1 -1
- package/packages/datadog-plugin-google-cloud-pubsub/src/index.js +1 -1
- package/packages/datadog-plugin-google-cloud-pubsub/src/producer.js +7 -6
- package/packages/datadog-plugin-graphql/src/execute.js +1 -1
- package/packages/datadog-plugin-graphql/src/index.js +1 -1
- package/packages/datadog-plugin-graphql/src/parse.js +1 -1
- package/packages/datadog-plugin-graphql/src/resolve.js +1 -1
- package/packages/datadog-plugin-graphql/src/validate.js +1 -1
- package/packages/datadog-plugin-grpc/src/client.js +1 -1
- package/packages/datadog-plugin-grpc/src/index.js +1 -1
- package/packages/datadog-plugin-grpc/src/server.js +1 -1
- package/packages/datadog-plugin-hapi/src/index.js +1 -1
- package/packages/datadog-plugin-http/src/client.js +2 -2
- package/packages/datadog-plugin-http/src/index.js +1 -1
- package/packages/datadog-plugin-http/src/server.js +3 -3
- package/packages/datadog-plugin-http2/src/client.js +4 -3
- package/packages/datadog-plugin-http2/src/index.js +1 -1
- package/packages/datadog-plugin-http2/src/server.js +3 -3
- package/packages/datadog-plugin-ioredis/src/index.js +1 -1
- package/packages/datadog-plugin-jest/src/index.js +53 -19
- package/packages/datadog-plugin-kafkajs/src/consumer.js +1 -1
- package/packages/datadog-plugin-kafkajs/src/index.js +1 -1
- package/packages/datadog-plugin-kafkajs/src/producer.js +1 -1
- package/packages/datadog-plugin-koa/src/index.js +1 -1
- package/packages/datadog-plugin-mariadb/src/index.js +18 -1
- package/packages/datadog-plugin-memcached/src/index.js +3 -2
- package/packages/datadog-plugin-microgateway-core/src/index.js +1 -1
- package/packages/datadog-plugin-mocha/src/index.js +13 -9
- package/packages/datadog-plugin-moleculer/src/client.js +1 -1
- package/packages/datadog-plugin-moleculer/src/index.js +1 -1
- package/packages/datadog-plugin-moleculer/src/server.js +1 -1
- package/packages/datadog-plugin-mongodb-core/src/index.js +1 -1
- package/packages/datadog-plugin-mysql/src/index.js +3 -2
- package/packages/datadog-plugin-mysql2/src/index.js +1 -1
- package/packages/datadog-plugin-net/src/index.js +9 -75
- package/packages/datadog-plugin-net/src/ipc.js +1 -1
- package/packages/datadog-plugin-net/src/tcp.js +3 -2
- package/packages/datadog-plugin-next/src/index.js +3 -3
- package/packages/datadog-plugin-opensearch/src/index.js +1 -1
- package/packages/datadog-plugin-oracledb/src/index.js +3 -2
- package/packages/datadog-plugin-paperplane/src/index.js +1 -1
- package/packages/datadog-plugin-paperplane/src/logger.js +1 -1
- package/packages/datadog-plugin-paperplane/src/server.js +1 -1
- package/packages/datadog-plugin-pg/src/index.js +3 -2
- package/packages/datadog-plugin-pino/src/index.js +1 -1
- package/packages/datadog-plugin-playwright/src/index.js +5 -4
- package/packages/datadog-plugin-redis/src/index.js +3 -2
- package/packages/datadog-plugin-restify/src/index.js +1 -1
- package/packages/datadog-plugin-rhea/src/consumer.js +1 -1
- package/packages/datadog-plugin-rhea/src/index.js +1 -1
- package/packages/datadog-plugin-rhea/src/producer.js +3 -2
- package/packages/datadog-plugin-router/src/index.js +8 -8
- package/packages/datadog-plugin-sharedb/src/index.js +1 -1
- package/packages/datadog-plugin-tedious/src/index.js +3 -2
- package/packages/datadog-plugin-web/src/index.js +1 -1
- package/packages/datadog-plugin-winston/src/index.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/gateway/engine/runner.js +2 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/analyzers.js +2 -0
- package/packages/dd-trace/src/appsec/iast/analyzers/vulnerability-analyzer.js +2 -2
- package/packages/dd-trace/src/appsec/iast/iast-context.js +6 -2
- package/packages/dd-trace/src/appsec/iast/iast-log.js +111 -0
- package/packages/dd-trace/src/appsec/iast/index.js +10 -6
- package/packages/dd-trace/src/appsec/iast/path-line.js +3 -6
- package/packages/dd-trace/src/appsec/iast/taint-tracking/index.js +2 -0
- package/packages/dd-trace/src/appsec/iast/taint-tracking/operations.js +2 -0
- package/packages/dd-trace/src/appsec/iast/taint-tracking/origin-types.js +2 -0
- package/packages/dd-trace/src/appsec/iast/taint-tracking/plugin.js +2 -0
- package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter.js +9 -4
- package/packages/dd-trace/src/appsec/iast/taint-tracking/taint-tracking-impl.js +5 -3
- package/packages/dd-trace/src/appsec/iast/telemetry/log_collector.js +96 -0
- package/packages/dd-trace/src/appsec/iast/telemetry/logs.js +87 -0
- package/packages/dd-trace/src/appsec/iast/vulnerability-reporter.js +27 -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/encode/json-encoder.js +27 -0
- package/packages/dd-trace/src/ci-visibility/exporters/ci-visibility-exporter.js +17 -9
- package/packages/dd-trace/src/ci-visibility/exporters/git/git_metadata.js +14 -8
- package/packages/dd-trace/src/ci-visibility/exporters/jest-worker/index.js +33 -0
- package/packages/dd-trace/src/ci-visibility/exporters/jest-worker/writer.js +37 -0
- package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-itr-configuration.js +12 -4
- package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +12 -4
- package/packages/dd-trace/src/config.js +24 -5
- package/packages/dd-trace/src/constants.js +2 -1
- package/packages/dd-trace/src/datastreams/encoding.js +80 -0
- package/packages/dd-trace/src/exporter.js +7 -9
- package/packages/dd-trace/src/exporters/common/agents.js +42 -0
- package/packages/dd-trace/src/exporters/common/docker.js +4 -1
- package/packages/dd-trace/src/exporters/common/request.js +1 -4
- package/packages/dd-trace/src/lambda/handler.js +19 -12
- 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/span.js +5 -0
- package/packages/dd-trace/src/opentracing/span_context.js +1 -1
- package/packages/dd-trace/src/plugin_manager.js +7 -7
- package/packages/dd-trace/src/plugins/ci_plugin.js +20 -17
- package/packages/dd-trace/src/plugins/index.js +1 -0
- package/packages/dd-trace/src/plugins/log_plugin.js +1 -1
- package/packages/dd-trace/src/plugins/outgoing.js +2 -1
- package/packages/dd-trace/src/plugins/tracing.js +1 -1
- package/packages/dd-trace/src/plugins/util/ci.js +12 -0
- 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/plugins/util/ip_extractor.js +23 -27
- package/packages/dd-trace/src/plugins/util/test.js +26 -7
- package/packages/dd-trace/src/profiler.js +3 -0
- package/packages/dd-trace/src/profiling/config.js +92 -20
- package/packages/dd-trace/src/profiling/constants.js +16 -0
- package/packages/dd-trace/src/profiling/exporter_cli.js +62 -0
- package/packages/dd-trace/src/profiling/exporters/agent.js +2 -1
- package/packages/dd-trace/src/profiling/exporters/file.js +13 -2
- package/packages/dd-trace/src/profiling/profiler.js +42 -12
- package/packages/dd-trace/src/profiling/profilers/space.js +21 -1
- 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 +71 -54
- package/packages/dd-trace/src/startup-log.js +3 -6
- package/packages/dd-trace/src/telemetry/index.js +16 -2
- package/packages/dd-trace/src/tracer.js +0 -16
- package/packages/dd-trace/src/util.js +10 -1
- package/scripts/install_plugin_modules.js +5 -1
- package/scripts/junit_report.js +0 -25
- package/scripts/tdd.js +0 -34
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
+
const { CLIENT_PORT_KEY } = require('../../dd-trace/src/constants')
|
|
3
4
|
const DatabasePlugin = require('../../dd-trace/src/plugins/database')
|
|
4
5
|
|
|
5
6
|
class PGPlugin extends DatabasePlugin {
|
|
6
|
-
static get
|
|
7
|
+
static get id () { return 'pg' }
|
|
7
8
|
static get operation () { return 'query' }
|
|
8
9
|
static get system () { return 'postgres' }
|
|
9
10
|
|
|
@@ -22,7 +23,7 @@ class PGPlugin extends DatabasePlugin {
|
|
|
22
23
|
'db.name': params.database,
|
|
23
24
|
'db.user': params.user,
|
|
24
25
|
'out.host': params.host,
|
|
25
|
-
|
|
26
|
+
[CLIENT_PORT_KEY]: params.port
|
|
26
27
|
}
|
|
27
28
|
})
|
|
28
29
|
|
|
@@ -13,7 +13,7 @@ const { RESOURCE_NAME } = require('../../../ext/tags')
|
|
|
13
13
|
const { COMPONENT } = require('../../dd-trace/src/constants')
|
|
14
14
|
|
|
15
15
|
class PlaywrightPlugin extends CiPlugin {
|
|
16
|
-
static get
|
|
16
|
+
static get id () {
|
|
17
17
|
return 'playwright'
|
|
18
18
|
}
|
|
19
19
|
|
|
@@ -39,13 +39,14 @@ class PlaywrightPlugin extends CiPlugin {
|
|
|
39
39
|
const testSuiteMetadata = getTestSuiteCommonTags(
|
|
40
40
|
this.command,
|
|
41
41
|
this.frameworkVersion,
|
|
42
|
-
testSuite
|
|
42
|
+
testSuite,
|
|
43
|
+
'playwright'
|
|
43
44
|
)
|
|
44
45
|
|
|
45
46
|
const testSuiteSpan = this.tracer.startSpan('playwright.test_suite', {
|
|
46
47
|
childOf: this.testModuleSpan,
|
|
47
48
|
tags: {
|
|
48
|
-
[COMPONENT]: this.constructor.
|
|
49
|
+
[COMPONENT]: this.constructor.id,
|
|
49
50
|
...this.testEnvironmentMetadata,
|
|
50
51
|
...testSuiteMetadata
|
|
51
52
|
}
|
|
@@ -87,7 +88,7 @@ class PlaywrightPlugin extends CiPlugin {
|
|
|
87
88
|
childOf: span,
|
|
88
89
|
startTime: stepStartTime,
|
|
89
90
|
tags: {
|
|
90
|
-
[COMPONENT]: this.constructor.
|
|
91
|
+
[COMPONENT]: this.constructor.id,
|
|
91
92
|
'playwright.step': step.title,
|
|
92
93
|
[RESOURCE_NAME]: step.title
|
|
93
94
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
+
const { CLIENT_PORT_KEY } = require('../../dd-trace/src/constants')
|
|
3
4
|
const CachePlugin = require('../../dd-trace/src/plugins/cache')
|
|
4
5
|
const urlFilter = require('../../dd-trace/src/plugins/util/urlfilter')
|
|
5
6
|
|
|
6
7
|
class RedisPlugin extends CachePlugin {
|
|
7
|
-
static get
|
|
8
|
+
static get id () { return 'redis' }
|
|
8
9
|
static get system () { return 'redis' }
|
|
9
10
|
|
|
10
11
|
start ({ db, command, args, connectionOptions = {}, connectionName }) {
|
|
@@ -20,7 +21,7 @@ class RedisPlugin extends CachePlugin {
|
|
|
20
21
|
'db.name': db || '0',
|
|
21
22
|
'redis.raw_command': formatCommand(command, args),
|
|
22
23
|
'out.host': connectionOptions.host,
|
|
23
|
-
|
|
24
|
+
[CLIENT_PORT_KEY]: connectionOptions.port
|
|
24
25
|
}
|
|
25
26
|
})
|
|
26
27
|
}
|
|
@@ -4,7 +4,7 @@ const ConsumerPlugin = require('../../dd-trace/src/plugins/consumer')
|
|
|
4
4
|
const { storage } = require('../../datadog-core')
|
|
5
5
|
|
|
6
6
|
class RheaConsumerPlugin extends ConsumerPlugin {
|
|
7
|
-
static get
|
|
7
|
+
static get id () { return 'rhea' }
|
|
8
8
|
|
|
9
9
|
constructor (...args) {
|
|
10
10
|
super(...args)
|
|
@@ -5,7 +5,7 @@ const ConsumerPlugin = require('./consumer')
|
|
|
5
5
|
const CompositePlugin = require('../../dd-trace/src/plugins/composite')
|
|
6
6
|
|
|
7
7
|
class RheaPlugin extends CompositePlugin {
|
|
8
|
-
static get
|
|
8
|
+
static get id () { return 'rhea' }
|
|
9
9
|
static get plugins () {
|
|
10
10
|
return {
|
|
11
11
|
producer: ProducerPlugin,
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
+
const { CLIENT_PORT_KEY } = require('../../dd-trace/src/constants')
|
|
3
4
|
const ProducerPlugin = require('../../dd-trace/src/plugins/producer')
|
|
4
5
|
|
|
5
6
|
class RheaProducerPlugin extends ProducerPlugin {
|
|
6
|
-
static get
|
|
7
|
+
static get id () { return 'rhea' }
|
|
7
8
|
static get operation () { return 'send' }
|
|
8
9
|
|
|
9
10
|
constructor (...args) {
|
|
@@ -24,7 +25,7 @@ class RheaProducerPlugin extends ProducerPlugin {
|
|
|
24
25
|
'amqp.link.target.address': name,
|
|
25
26
|
'amqp.link.role': 'sender',
|
|
26
27
|
'out.host': host,
|
|
27
|
-
|
|
28
|
+
[CLIENT_PORT_KEY]: port
|
|
28
29
|
}
|
|
29
30
|
})
|
|
30
31
|
}
|
|
@@ -7,7 +7,7 @@ const { storage } = require('../../datadog-core')
|
|
|
7
7
|
const { COMPONENT } = require('../../dd-trace/src/constants')
|
|
8
8
|
|
|
9
9
|
class RouterPlugin extends WebPlugin {
|
|
10
|
-
static get
|
|
10
|
+
static get id () {
|
|
11
11
|
return 'router'
|
|
12
12
|
}
|
|
13
13
|
|
|
@@ -17,7 +17,7 @@ class RouterPlugin extends WebPlugin {
|
|
|
17
17
|
this._storeStack = []
|
|
18
18
|
this._contexts = new WeakMap()
|
|
19
19
|
|
|
20
|
-
this.addSub(`apm:${this.constructor.
|
|
20
|
+
this.addSub(`apm:${this.constructor.id}:middleware:enter`, ({ req, name, route }) => {
|
|
21
21
|
const childOf = this._getActive(req) || this._getStoreSpan()
|
|
22
22
|
|
|
23
23
|
if (!childOf) return
|
|
@@ -37,7 +37,7 @@ class RouterPlugin extends WebPlugin {
|
|
|
37
37
|
web.setRoute(req, context.route)
|
|
38
38
|
})
|
|
39
39
|
|
|
40
|
-
this.addSub(`apm:${this.constructor.
|
|
40
|
+
this.addSub(`apm:${this.constructor.id}:middleware:next`, ({ req }) => {
|
|
41
41
|
const context = this._contexts.get(req)
|
|
42
42
|
|
|
43
43
|
if (!context) return
|
|
@@ -45,7 +45,7 @@ class RouterPlugin extends WebPlugin {
|
|
|
45
45
|
context.stack.pop()
|
|
46
46
|
})
|
|
47
47
|
|
|
48
|
-
this.addSub(`apm:${this.constructor.
|
|
48
|
+
this.addSub(`apm:${this.constructor.id}:middleware:finish`, ({ req }) => {
|
|
49
49
|
const context = this._contexts.get(req)
|
|
50
50
|
|
|
51
51
|
if (!context || context.middleware.length === 0) return
|
|
@@ -53,13 +53,13 @@ class RouterPlugin extends WebPlugin {
|
|
|
53
53
|
context.middleware.pop().finish()
|
|
54
54
|
})
|
|
55
55
|
|
|
56
|
-
this.addSub(`apm:${this.constructor.
|
|
56
|
+
this.addSub(`apm:${this.constructor.id}:middleware:exit`, ({ req }) => {
|
|
57
57
|
const savedStore = this._storeStack.pop()
|
|
58
58
|
const span = savedStore && savedStore.span
|
|
59
59
|
this.enter(span, savedStore)
|
|
60
60
|
})
|
|
61
61
|
|
|
62
|
-
this.addSub(`apm:${this.constructor.
|
|
62
|
+
this.addSub(`apm:${this.constructor.id}:middleware:error`, ({ req, error }) => {
|
|
63
63
|
web.addError(req, error)
|
|
64
64
|
|
|
65
65
|
if (!this.config.middleware) return
|
|
@@ -104,10 +104,10 @@ class RouterPlugin extends WebPlugin {
|
|
|
104
104
|
return childOf
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
-
const span = this.tracer.startSpan(`${this.constructor.
|
|
107
|
+
const span = this.tracer.startSpan(`${this.constructor.id}.middleware`, {
|
|
108
108
|
childOf,
|
|
109
109
|
tags: {
|
|
110
|
-
[COMPONENT]: this.constructor.
|
|
110
|
+
[COMPONENT]: this.constructor.id,
|
|
111
111
|
'resource.name': name || '<anonymous>'
|
|
112
112
|
}
|
|
113
113
|
})
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
const ServerPlugin = require('../../dd-trace/src/plugins/server')
|
|
4
4
|
|
|
5
5
|
class SharedbPlugin extends ServerPlugin {
|
|
6
|
-
static get
|
|
6
|
+
static get id () { return 'sharedb' }
|
|
7
7
|
|
|
8
8
|
start ({ actionName, request }) {
|
|
9
9
|
const span = this.startSpan('sharedb.request', {
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
+
const { CLIENT_PORT_KEY } = require('../../dd-trace/src/constants')
|
|
3
4
|
const DatabasePlugin = require('../../dd-trace/src/plugins/database')
|
|
4
5
|
|
|
5
6
|
class TediousPlugin extends DatabasePlugin {
|
|
6
|
-
static get
|
|
7
|
+
static get id () { return 'tedious' }
|
|
7
8
|
static get operation () { return 'request' } // TODO: change to match other database plugins
|
|
8
9
|
static get system () { return 'mssql' }
|
|
9
10
|
|
|
@@ -17,7 +18,7 @@ class TediousPlugin extends DatabasePlugin {
|
|
|
17
18
|
'db.type': 'mssql',
|
|
18
19
|
'component': 'tedious',
|
|
19
20
|
'out.host': connectionConfig.server,
|
|
20
|
-
|
|
21
|
+
[CLIENT_PORT_KEY]: connectionConfig.options.port,
|
|
21
22
|
'db.user': connectionConfig.userName || connectionConfig.authentication.options.userName,
|
|
22
23
|
'db.name': connectionConfig.options.database,
|
|
23
24
|
'db.instance': connectionConfig.options.instanceName
|
|
@@ -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,6 +1,7 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
const als = require('../als')
|
|
4
|
+
const log = require('../../../log')
|
|
4
5
|
|
|
5
6
|
let lock = false // lock to prevent recursive calls to runSubscriptions
|
|
6
7
|
|
|
@@ -25,7 +26,7 @@ function runSubscriptions (subscriptions, params) {
|
|
|
25
26
|
try {
|
|
26
27
|
result = subscription.callback.method(params, store)
|
|
27
28
|
} catch (err) {
|
|
28
|
-
|
|
29
|
+
log.warn(`Error running subscription ${err}`)
|
|
29
30
|
}
|
|
30
31
|
|
|
31
32
|
results.push(result)
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const Plugin = require('../../../../src/plugins/plugin')
|
|
4
4
|
const { storage } = require('../../../../../datadog-core')
|
|
5
|
-
const
|
|
5
|
+
const iastLog = require('../iast-log')
|
|
6
6
|
const { getFirstNonDDPathAndLine } = require('../path-line')
|
|
7
7
|
const { createVulnerability, addVulnerability } = require('../vulnerability-reporter')
|
|
8
8
|
const { getIastContext } = require('../iast-context')
|
|
@@ -19,7 +19,7 @@ class Analyzer extends Plugin {
|
|
|
19
19
|
try {
|
|
20
20
|
handler(message, name)
|
|
21
21
|
} catch (e) {
|
|
22
|
-
|
|
22
|
+
iastLog.errorAndPublish(e)
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
}
|
|
@@ -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
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const log = require('../../log')
|
|
4
|
+
const telemetryLogs = require('./telemetry/logs')
|
|
5
|
+
const { calculateDDBasePath } = require('../../util')
|
|
6
|
+
|
|
7
|
+
const ddBasePath = calculateDDBasePath(__dirname)
|
|
8
|
+
const EOL = '\n'
|
|
9
|
+
const STACK_FRAME_LINE_REGEX = /^\s*at\s/gm
|
|
10
|
+
|
|
11
|
+
function sanitize (logEntry, stack) {
|
|
12
|
+
if (!stack) return logEntry
|
|
13
|
+
|
|
14
|
+
let stackLines = stack.split(EOL)
|
|
15
|
+
|
|
16
|
+
const firstIndex = stackLines.findIndex(l => l.match(STACK_FRAME_LINE_REGEX))
|
|
17
|
+
|
|
18
|
+
const isDDCode = firstIndex > -1 && stackLines[firstIndex].includes(ddBasePath)
|
|
19
|
+
stackLines = stackLines
|
|
20
|
+
.filter((line, index) => (isDDCode && index < firstIndex) || line.includes(ddBasePath))
|
|
21
|
+
.map(line => line.replace(ddBasePath, ''))
|
|
22
|
+
|
|
23
|
+
logEntry.stack_trace = stackLines.join(EOL)
|
|
24
|
+
|
|
25
|
+
if (!isDDCode) {
|
|
26
|
+
logEntry.message = 'omitted'
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return logEntry
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function getTelemetryLog (data, level) {
|
|
33
|
+
try {
|
|
34
|
+
data = typeof data === 'function' ? data() : data
|
|
35
|
+
|
|
36
|
+
let message
|
|
37
|
+
if (typeof data !== 'object' || !data) {
|
|
38
|
+
message = String(data)
|
|
39
|
+
} else {
|
|
40
|
+
message = String(data.message || data)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
let logEntry = {
|
|
44
|
+
message,
|
|
45
|
+
level
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (data.stack) {
|
|
49
|
+
logEntry = sanitize(logEntry, data.stack)
|
|
50
|
+
if (logEntry.stack_trace === '') {
|
|
51
|
+
return
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return logEntry
|
|
56
|
+
} catch (e) {
|
|
57
|
+
log.error(e)
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const iastLog = {
|
|
62
|
+
debug (data) {
|
|
63
|
+
log.debug(data)
|
|
64
|
+
return this
|
|
65
|
+
},
|
|
66
|
+
|
|
67
|
+
info (data) {
|
|
68
|
+
log.info(data)
|
|
69
|
+
return this
|
|
70
|
+
},
|
|
71
|
+
|
|
72
|
+
warn (data) {
|
|
73
|
+
log.warn(data)
|
|
74
|
+
return this
|
|
75
|
+
},
|
|
76
|
+
|
|
77
|
+
error (data) {
|
|
78
|
+
log.error(data)
|
|
79
|
+
return this
|
|
80
|
+
},
|
|
81
|
+
|
|
82
|
+
publish (data, level) {
|
|
83
|
+
if (telemetryLogs.isLevelEnabled(level)) {
|
|
84
|
+
const telemetryLog = getTelemetryLog(data, level)
|
|
85
|
+
telemetryLogs.publish(telemetryLog)
|
|
86
|
+
}
|
|
87
|
+
return this
|
|
88
|
+
},
|
|
89
|
+
|
|
90
|
+
debugAndPublish (data) {
|
|
91
|
+
this.debug(data)
|
|
92
|
+
return this.publish(data, 'DEBUG')
|
|
93
|
+
},
|
|
94
|
+
|
|
95
|
+
infoAndPublish (data) {
|
|
96
|
+
this.info(data)
|
|
97
|
+
return this.publish(data, 'DEBUG')
|
|
98
|
+
},
|
|
99
|
+
|
|
100
|
+
warnAndPublish (data) {
|
|
101
|
+
this.warn(data)
|
|
102
|
+
return this.publish(data, 'WARN')
|
|
103
|
+
},
|
|
104
|
+
|
|
105
|
+
errorAndPublish (data) {
|
|
106
|
+
this.error(data)
|
|
107
|
+
return this.publish(data, 'ERROR')
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
module.exports = iastLog
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const vulnerabilityReporter = require('./vulnerability-reporter')
|
|
2
2
|
const { enableAllAnalyzers, disableAllAnalyzers } = require('./analyzers')
|
|
3
3
|
const web = require('../../plugins/util/web')
|
|
4
4
|
const { storage } = require('../../../../datadog-core')
|
|
@@ -6,7 +6,7 @@ const overheadController = require('./overhead-controller')
|
|
|
6
6
|
const dc = require('diagnostics_channel')
|
|
7
7
|
const iastContextFunctions = require('./iast-context')
|
|
8
8
|
const { enableTaintTracking, disableTaintTracking, createTransaction, removeTransaction } = require('./taint-tracking')
|
|
9
|
-
|
|
9
|
+
const telemetryLogs = require('./telemetry/logs')
|
|
10
10
|
const IAST_ENABLED_TAG_KEY = '_dd.iast.enabled'
|
|
11
11
|
|
|
12
12
|
// TODO Change to `apm:http:server:request:[start|close]` when the subscription
|
|
@@ -21,7 +21,8 @@ function enable (config, _tracer) {
|
|
|
21
21
|
requestClose.subscribe(onIncomingHttpRequestEnd)
|
|
22
22
|
overheadController.configure(config.iast)
|
|
23
23
|
overheadController.startGlobalContext()
|
|
24
|
-
|
|
24
|
+
vulnerabilityReporter.start(config, _tracer)
|
|
25
|
+
telemetryLogs.start()
|
|
25
26
|
}
|
|
26
27
|
|
|
27
28
|
function disable () {
|
|
@@ -30,6 +31,8 @@ function disable () {
|
|
|
30
31
|
overheadController.finishGlobalContext()
|
|
31
32
|
if (requestStart.hasSubscribers) requestStart.unsubscribe(onIncomingHttpRequestStart)
|
|
32
33
|
if (requestClose.hasSubscribers) requestClose.unsubscribe(onIncomingHttpRequestEnd)
|
|
34
|
+
vulnerabilityReporter.stop()
|
|
35
|
+
telemetryLogs.stop()
|
|
33
36
|
}
|
|
34
37
|
|
|
35
38
|
function onIncomingHttpRequestStart (data) {
|
|
@@ -58,15 +61,16 @@ function onIncomingHttpRequestStart (data) {
|
|
|
58
61
|
function onIncomingHttpRequestEnd (data) {
|
|
59
62
|
if (data && data.req) {
|
|
60
63
|
const store = storage.getStore()
|
|
61
|
-
const
|
|
64
|
+
const topContext = web.getContext(data.req)
|
|
65
|
+
const iastContext = iastContextFunctions.getIastContext(store, topContext)
|
|
62
66
|
if (iastContext && iastContext.rootSpan) {
|
|
63
67
|
const vulnerabilities = iastContext.vulnerabilities
|
|
64
68
|
const rootSpan = iastContext.rootSpan
|
|
65
|
-
sendVulnerabilities(vulnerabilities, rootSpan)
|
|
69
|
+
vulnerabilityReporter.sendVulnerabilities(vulnerabilities, rootSpan)
|
|
66
70
|
removeTransaction(iastContext)
|
|
67
71
|
}
|
|
68
72
|
// TODO web.getContext(data.req) is required when the request is aborted
|
|
69
|
-
if (iastContextFunctions.cleanIastContext(store,
|
|
73
|
+
if (iastContextFunctions.cleanIastContext(store, topContext, iastContext)) {
|
|
70
74
|
overheadController.releaseRequest()
|
|
71
75
|
}
|
|
72
76
|
}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
1
3
|
const path = require('path')
|
|
2
4
|
const process = require('process')
|
|
5
|
+
const { calculateDDBasePath } = require('../../util')
|
|
3
6
|
const pathLine = {
|
|
4
7
|
getFirstNonDDPathAndLine,
|
|
5
8
|
getFirstNonDDPathAndLineFromCallsites, // Exported only for test purposes
|
|
@@ -19,12 +22,6 @@ const EXCLUDED_PATH_PREFIXES = [
|
|
|
19
22
|
'async_hooks'
|
|
20
23
|
]
|
|
21
24
|
|
|
22
|
-
function calculateDDBasePath (dirname) {
|
|
23
|
-
const dirSteps = dirname.split(path.sep)
|
|
24
|
-
const packagesIndex = dirSteps.lastIndexOf('packages')
|
|
25
|
-
return dirSteps.slice(0, packagesIndex).join(path.sep) + path.sep
|
|
26
|
-
}
|
|
27
|
-
|
|
28
25
|
function getCallSiteInfo () {
|
|
29
26
|
const previousPrepareStackTrace = Error.prepareStackTrace
|
|
30
27
|
const previousStackTraceLimit = Error.stackTraceLimit
|