dd-trace 3.15.0 → 3.17.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 +53 -0
- package/ci/init.js +9 -1
- package/ext/exporters.d.ts +2 -1
- package/ext/exporters.js +2 -1
- package/index.d.ts +6 -2
- package/package.json +24 -19
- package/packages/datadog-esbuild/index.js +104 -0
- 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/hook.js +13 -3
- package/packages/datadog-instrumentations/src/helpers/hooks.js +1 -0
- package/packages/datadog-instrumentations/src/helpers/instrument.js +6 -0
- package/packages/datadog-instrumentations/src/helpers/register.js +2 -2
- package/packages/datadog-instrumentations/src/jest.js +35 -3
- 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 +32 -4
- package/packages/datadog-instrumentations/src/pg.js +16 -11
- package/packages/datadog-instrumentations/src/playwright.js +2 -2
- 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 +2 -2
- 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 +2 -2
- 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/{templates/blocked.html → blocked_templates.js} +19 -1
- package/packages/dd-trace/src/appsec/blocking.js +9 -24
- 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/path-traversal-analyzer.js +12 -0
- package/packages/dd-trace/src/appsec/iast/analyzers/sql-injection-analyzer.js +1 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/vulnerability-analyzer.js +11 -5
- package/packages/dd-trace/src/appsec/iast/iast-log.js +111 -0
- package/packages/dd-trace/src/appsec/iast/index.js +8 -4
- package/packages/dd-trace/src/appsec/iast/path-line.js +3 -6
- package/packages/dd-trace/src/appsec/iast/taint-tracking/index.js +11 -2
- package/packages/dd-trace/src/appsec/iast/taint-tracking/operations.js +11 -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 +5 -3
- 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 -18
- package/packages/dd-trace/src/appsec/recommended.json +43 -14
- package/packages/dd-trace/src/appsec/remote_config/index.js +1 -1
- package/packages/dd-trace/src/appsec/sdk/index.js +2 -2
- 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 +2 -9
- package/packages/dd-trace/src/ci-visibility/exporters/git/git_metadata.js +7 -7
- 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 +8 -2
- package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +8 -2
- package/packages/dd-trace/src/config.js +44 -22
- package/packages/dd-trace/src/constants.js +2 -1
- package/packages/dd-trace/src/datastreams/encoding.js +80 -0
- package/packages/dd-trace/src/dcitm.js +51 -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 +14 -6
- package/packages/dd-trace/src/opentracing/propagation/log.js +23 -7
- package/packages/dd-trace/src/opentracing/propagation/text_map.js +28 -2
- package/packages/dd-trace/src/opentracing/span.js +19 -3
- package/packages/dd-trace/src/opentracing/span_context.js +3 -1
- package/packages/dd-trace/src/opentracing/tracer.js +3 -1
- package/packages/dd-trace/src/plugin_manager.js +7 -7
- package/packages/dd-trace/src/plugins/ci_plugin.js +16 -16
- 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/ip_extractor.js +23 -27
- package/packages/dd-trace/src/plugins/util/test.js +26 -7
- package/packages/dd-trace/src/profiling/config.js +87 -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/profiler.js +21 -8
- package/packages/dd-trace/src/profiling/profilers/space.js +21 -1
- package/packages/dd-trace/src/span_sampler.js +3 -2
- package/packages/dd-trace/src/telemetry/index.js +16 -2
- package/packages/dd-trace/src/util.js +10 -1
- package/scripts/install_plugin_modules.js +5 -1
- package/packages/dd-trace/src/appsec/templates/blocked.json +0 -8
- 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 ClientPlugin = require('../../dd-trace/src/plugins/client')
|
|
4
5
|
|
|
5
6
|
class NetTCPPlugin extends ClientPlugin {
|
|
6
|
-
static get
|
|
7
|
+
static get id () { return 'net' }
|
|
7
8
|
static get operation () { return 'tcp' }
|
|
8
9
|
|
|
9
10
|
constructor (...args) {
|
|
@@ -37,7 +38,7 @@ class NetTCPPlugin extends ClientPlugin {
|
|
|
37
38
|
metrics: {
|
|
38
39
|
'tcp.remote.port': port,
|
|
39
40
|
'tcp.local.port': 0,
|
|
40
|
-
|
|
41
|
+
[CLIENT_PORT_KEY]: port
|
|
41
42
|
}
|
|
42
43
|
})
|
|
43
44
|
}
|
|
@@ -6,7 +6,7 @@ const analyticsSampler = require('../../dd-trace/src/analytics_sampler')
|
|
|
6
6
|
const { COMPONENT } = require('../../dd-trace/src/constants')
|
|
7
7
|
|
|
8
8
|
class NextPlugin extends Plugin {
|
|
9
|
-
static get
|
|
9
|
+
static get id () {
|
|
10
10
|
return 'next'
|
|
11
11
|
}
|
|
12
12
|
|
|
@@ -21,7 +21,7 @@ class NextPlugin extends Plugin {
|
|
|
21
21
|
const span = this.tracer.startSpan('next.request', {
|
|
22
22
|
childOf,
|
|
23
23
|
tags: {
|
|
24
|
-
[COMPONENT]: this.constructor.
|
|
24
|
+
[COMPONENT]: this.constructor.id,
|
|
25
25
|
'service.name': this.config.service || this.tracer._service,
|
|
26
26
|
'resource.name': req.method,
|
|
27
27
|
'span.type': 'web',
|
|
@@ -69,7 +69,7 @@ class NextPlugin extends Plugin {
|
|
|
69
69
|
const req = this._requests.get(span)
|
|
70
70
|
|
|
71
71
|
span.addTags({
|
|
72
|
-
[COMPONENT]: this.constructor.
|
|
72
|
+
[COMPONENT]: this.constructor.id,
|
|
73
73
|
'resource.name': `${req.method} ${page}`.trim(),
|
|
74
74
|
'next.page': page
|
|
75
75
|
})
|
|
@@ -1,10 +1,11 @@
|
|
|
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
|
const log = require('../../dd-trace/src/log')
|
|
5
6
|
|
|
6
7
|
class OracledbPlugin extends DatabasePlugin {
|
|
7
|
-
static get
|
|
8
|
+
static get id () { return 'oracledb' }
|
|
8
9
|
static get system () { return 'oracle' }
|
|
9
10
|
|
|
10
11
|
start ({ query, connAttrs }) {
|
|
@@ -20,7 +21,7 @@ class OracledbPlugin extends DatabasePlugin {
|
|
|
20
21
|
'db.user': this.config.user,
|
|
21
22
|
'db.instance': url.pathname && url.pathname.substring(1),
|
|
22
23
|
'db.hostname': url.hostname,
|
|
23
|
-
|
|
24
|
+
[CLIENT_PORT_KEY]: url.port
|
|
24
25
|
}
|
|
25
26
|
})
|
|
26
27
|
}
|
|
@@ -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,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
/* eslint-disable max-len */
|
|
2
|
+
'use strict'
|
|
3
|
+
|
|
4
|
+
const html = `<!-- Sorry, you've been blocked -->
|
|
2
5
|
<!DOCTYPE html>
|
|
3
6
|
<html lang="en">
|
|
4
7
|
|
|
@@ -97,3 +100,18 @@
|
|
|
97
100
|
</body>
|
|
98
101
|
|
|
99
102
|
</html>
|
|
103
|
+
`
|
|
104
|
+
|
|
105
|
+
const json = `{
|
|
106
|
+
"errors": [
|
|
107
|
+
{
|
|
108
|
+
"title": "You've been blocked",
|
|
109
|
+
"detail": "Sorry, you cannot access this page. Please contact the customer service team. Security provided by Datadog."
|
|
110
|
+
}
|
|
111
|
+
]
|
|
112
|
+
}`
|
|
113
|
+
|
|
114
|
+
module.exports = {
|
|
115
|
+
html,
|
|
116
|
+
json
|
|
117
|
+
}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
const log = require('../log')
|
|
4
|
-
const
|
|
4
|
+
const blockedTemplates = require('./blocked_templates')
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
let
|
|
8
|
-
let templateHtml = ''
|
|
9
|
-
let templateJson = ''
|
|
6
|
+
let templateHtml = blockedTemplates.html
|
|
7
|
+
let templateJson = blockedTemplates.json
|
|
10
8
|
|
|
11
9
|
function block (req, res, rootSpan, abortController) {
|
|
12
10
|
if (res.headersSent) {
|
|
@@ -42,29 +40,16 @@ function block (req, res, rootSpan, abortController) {
|
|
|
42
40
|
}
|
|
43
41
|
}
|
|
44
42
|
|
|
45
|
-
function
|
|
46
|
-
if (
|
|
47
|
-
templateHtml =
|
|
48
|
-
templateJson = fs.readFileSync(config.appsec.blockedTemplateJson)
|
|
49
|
-
templateLoaded = true
|
|
43
|
+
function setTemplates (config) {
|
|
44
|
+
if (config.appsec.blockedTemplateHtml) {
|
|
45
|
+
templateHtml = config.appsec.blockedTemplateHtml
|
|
50
46
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
async function loadTemplatesAsync (config) {
|
|
54
|
-
if (!templateLoaded) {
|
|
55
|
-
templateHtml = await fs.promises.readFile(config.appsec.blockedTemplateHtml)
|
|
56
|
-
templateJson = await fs.promises.readFile(config.appsec.blockedTemplateJson)
|
|
57
|
-
templateLoaded = true
|
|
47
|
+
if (config.appsec.blockedTemplateJson) {
|
|
48
|
+
templateJson = config.appsec.blockedTemplateJson
|
|
58
49
|
}
|
|
59
50
|
}
|
|
60
51
|
|
|
61
|
-
function resetTemplates () {
|
|
62
|
-
templateLoaded = false
|
|
63
|
-
}
|
|
64
|
-
|
|
65
52
|
module.exports = {
|
|
66
53
|
block,
|
|
67
|
-
|
|
68
|
-
loadTemplatesAsync,
|
|
69
|
-
resetTemplates
|
|
54
|
+
setTemplates
|
|
70
55
|
}
|
|
@@ -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)
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
|
+
|
|
3
|
+
const path = require('path')
|
|
2
4
|
const { getIastContext } = require('../iast-context')
|
|
3
5
|
const { storage } = require('../../../../../datadog-core')
|
|
4
6
|
const InjectionAnalyzer = require('./injection-analyzer')
|
|
@@ -37,6 +39,16 @@ class PathTraversalAnalyzer extends InjectionAnalyzer {
|
|
|
37
39
|
}
|
|
38
40
|
this.analyze(pathArguments)
|
|
39
41
|
})
|
|
42
|
+
|
|
43
|
+
this.exclusionList = [ path.join('node_modules', 'send') + path.sep ]
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
_isExcluded (location) {
|
|
47
|
+
let ret = false
|
|
48
|
+
if (location && location.path) {
|
|
49
|
+
ret = this.exclusionList.some(elem => location.path.includes(elem))
|
|
50
|
+
}
|
|
51
|
+
return ret
|
|
40
52
|
}
|
|
41
53
|
|
|
42
54
|
analyze (value) {
|
|
@@ -6,7 +6,7 @@ class SqlInjectionAnalyzer extends InjectionAnalyzer {
|
|
|
6
6
|
super('SQL_INJECTION')
|
|
7
7
|
this.addSub('apm:mysql:query:start', ({ sql }) => this.analyze(sql))
|
|
8
8
|
this.addSub('apm:mysql2:query:start', ({ sql }) => this.analyze(sql))
|
|
9
|
-
this.addSub('apm:pg:query:start', ({
|
|
9
|
+
this.addSub('apm:pg:query:start', ({ query }) => this.analyze(query.text))
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
12
|
|
|
@@ -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
|
}
|
|
@@ -32,12 +32,18 @@ class Analyzer extends Plugin {
|
|
|
32
32
|
return false
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
+
_isExcluded (location) {
|
|
36
|
+
return false
|
|
37
|
+
}
|
|
38
|
+
|
|
35
39
|
_report (value, context) {
|
|
36
40
|
const evidence = this._getEvidence(value, context)
|
|
37
41
|
const location = this._getLocation()
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
42
|
+
if (!this._isExcluded(location)) {
|
|
43
|
+
const spanId = context && context.rootSpan && context.rootSpan.context().toSpanId()
|
|
44
|
+
const vulnerability = createVulnerability(this._type, evidence, spanId, location)
|
|
45
|
+
addVulnerability(context, vulnerability)
|
|
46
|
+
}
|
|
41
47
|
}
|
|
42
48
|
|
|
43
49
|
_reportIfVulnerable (value, context) {
|
|
@@ -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
|