dd-trace 2.0.0-appsec-beta.3 → 2.0.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.
Files changed (91) hide show
  1. package/MIGRATING.md +65 -0
  2. package/NOTICE +4 -0
  3. package/ci/cypress/plugin.js +3 -0
  4. package/ci/cypress/support.js +1 -0
  5. package/ci/init.js +13 -0
  6. package/ci/jest/env.js +14 -0
  7. package/index.d.ts +35 -48
  8. package/package.json +7 -4
  9. package/packages/datadog-instrumentations/index.js +10 -0
  10. package/packages/datadog-instrumentations/src/bluebird.js +26 -0
  11. package/packages/datadog-instrumentations/src/dns.js +94 -0
  12. package/packages/datadog-instrumentations/src/helpers/instrument.js +120 -0
  13. package/packages/datadog-instrumentations/src/helpers/promise.js +29 -0
  14. package/packages/datadog-instrumentations/src/memcached.js +53 -0
  15. package/packages/datadog-instrumentations/src/mysql.js +67 -0
  16. package/packages/datadog-instrumentations/src/promise-js.js +15 -0
  17. package/packages/datadog-instrumentations/src/promise.js +14 -0
  18. package/packages/datadog-instrumentations/src/q.js +13 -0
  19. package/packages/datadog-instrumentations/src/when.js +14 -0
  20. package/packages/datadog-plugin-cucumber/src/index.js +4 -4
  21. package/packages/datadog-plugin-cypress/src/plugin.js +12 -2
  22. package/packages/datadog-plugin-cypress/src/support.js +21 -6
  23. package/packages/datadog-plugin-dns/src/index.js +65 -178
  24. package/packages/datadog-plugin-fs/src/index.js +7 -3
  25. package/packages/datadog-plugin-http/src/client.js +9 -24
  26. package/packages/datadog-plugin-http/src/server.js +5 -0
  27. package/packages/datadog-plugin-http2/src/client.js +1 -24
  28. package/packages/datadog-plugin-http2/src/server.js +2 -2
  29. package/packages/datadog-plugin-jest/src/jest-environment.js +4 -4
  30. package/packages/datadog-plugin-jest/src/jest-jasmine2.js +2 -2
  31. package/packages/datadog-plugin-knex/src/index.js +3 -3
  32. package/packages/datadog-plugin-memcached/src/index.js +41 -63
  33. package/packages/datadog-plugin-mocha/src/index.js +3 -2
  34. package/packages/datadog-plugin-moleculer/src/client.js +60 -0
  35. package/packages/datadog-plugin-moleculer/src/index.js +8 -0
  36. package/packages/datadog-plugin-moleculer/src/server.js +61 -0
  37. package/packages/datadog-plugin-moleculer/src/util.js +21 -0
  38. package/packages/datadog-plugin-mongoose/src/index.js +2 -2
  39. package/packages/datadog-plugin-mysql/src/index.js +37 -89
  40. package/packages/datadog-plugin-net/src/index.js +5 -0
  41. package/packages/datadog-plugin-pino/src/index.js +25 -1
  42. package/packages/datadog-plugin-redis/src/index.js +31 -1
  43. package/packages/datadog-plugin-router/src/index.js +28 -3
  44. package/packages/dd-trace/lib/version.js +1 -1
  45. package/packages/dd-trace/src/appsec/addresses.js +11 -4
  46. package/packages/dd-trace/src/appsec/callbacks/ddwaf.js +5 -8
  47. package/packages/dd-trace/src/{gateway → appsec/gateway}/als.js +1 -0
  48. package/packages/dd-trace/src/appsec/gateway/channels.js +11 -0
  49. package/packages/dd-trace/src/{gateway → appsec/gateway}/engine/engine.js +20 -30
  50. package/packages/dd-trace/src/{gateway → appsec/gateway}/engine/index.js +0 -0
  51. package/packages/dd-trace/src/{gateway → appsec/gateway}/engine/runner.js +2 -0
  52. package/packages/dd-trace/src/appsec/index.js +54 -38
  53. package/packages/dd-trace/src/appsec/recommended.json +1 -1
  54. package/packages/dd-trace/src/appsec/reporter.js +27 -10
  55. package/packages/dd-trace/src/config.js +31 -27
  56. package/packages/dd-trace/src/constants.js +6 -3
  57. package/packages/dd-trace/src/exporters/agent/request.js +8 -0
  58. package/packages/dd-trace/src/format.js +26 -39
  59. package/packages/dd-trace/src/instrumenter.js +6 -1
  60. package/packages/dd-trace/src/log.js +6 -15
  61. package/packages/dd-trace/src/noop/span_context.js +0 -1
  62. package/packages/dd-trace/src/noop/tracer.js +0 -6
  63. package/packages/dd-trace/src/opentracing/propagation/text_map.js +79 -46
  64. package/packages/dd-trace/src/opentracing/span.js +2 -7
  65. package/packages/dd-trace/src/opentracing/span_context.js +2 -4
  66. package/packages/dd-trace/src/opentracing/tracer.js +5 -23
  67. package/packages/dd-trace/src/plugin_manager.js +65 -0
  68. package/packages/dd-trace/src/plugins/index.js +1 -5
  69. package/packages/dd-trace/src/plugins/plugin.js +63 -0
  70. package/packages/dd-trace/src/plugins/util/ci.js +13 -4
  71. package/packages/dd-trace/src/plugins/util/redis.js +0 -2
  72. package/packages/dd-trace/src/plugins/util/test.js +9 -4
  73. package/packages/dd-trace/src/plugins/util/user-provided-git.js +17 -2
  74. package/packages/dd-trace/src/plugins/util/web.js +6 -16
  75. package/packages/dd-trace/src/priority_sampler.js +71 -19
  76. package/packages/dd-trace/src/profiling/exporters/agent.js +35 -34
  77. package/packages/dd-trace/src/proxy.js +39 -35
  78. package/packages/dd-trace/src/ritm.js +40 -16
  79. package/packages/dd-trace/src/span_processor.js +0 -7
  80. package/packages/dd-trace/src/tracer.js +5 -6
  81. package/scripts/install_plugin_modules.js +30 -1
  82. package/packages/datadog-plugin-bluebird/src/index.js +0 -69
  83. package/packages/datadog-plugin-promise/src/index.js +0 -17
  84. package/packages/datadog-plugin-promise-js/src/index.js +0 -20
  85. package/packages/datadog-plugin-q/src/index.js +0 -16
  86. package/packages/datadog-plugin-when/src/index.js +0 -17
  87. package/packages/dd-trace/src/gateway/channels.js +0 -8
  88. package/packages/dd-trace/src/gateway/dc_block.js +0 -68
  89. package/packages/dd-trace/src/plugins/util/ci-app-spec.json +0 -36
  90. package/packages/dd-trace/src/plugins/util/promise.js +0 -31
  91. package/packages/dd-trace/src/scope/noop/scope_manager.js +0 -28
@@ -1,69 +0,0 @@
1
- 'use strict'
2
-
3
- const tx = require('../../dd-trace/src/plugins/util/promise')
4
-
5
- const DD_LIB_COPIES = '_datadog_library_copies'
6
-
7
- function createGetNewLibraryCopyWrap (tracer, config, originalLib, shim) {
8
- return function wrapGetNewLibraryCopy (getNewLibraryCopy) {
9
- return function getNewLibraryCopyWithTrace () {
10
- const libraryCopy = getNewLibraryCopy.apply(this, arguments)
11
- shim.wrap(libraryCopy.prototype, '_then', tx.createWrapThen(tracer, config))
12
- shim.wrap(libraryCopy, 'getNewLibraryCopy', createGetNewLibraryCopyWrap(tracer, config, originalLib, shim))
13
- addToLibraryCopies(originalLib, libraryCopy)
14
- return libraryCopy
15
- }
16
- }
17
- }
18
-
19
- function addToLibraryCopies (originalLib, libraryCopy) {
20
- let libraryCopies = originalLib[DD_LIB_COPIES]
21
-
22
- if (!libraryCopies) {
23
- libraryCopies = new Set()
24
-
25
- Object.defineProperty(originalLib, DD_LIB_COPIES, {
26
- writable: true,
27
- configurable: true,
28
- value: libraryCopies
29
- })
30
- }
31
- libraryCopies.add(libraryCopy)
32
- }
33
-
34
- function unwrapLibraryCopies (originalLib, shim) {
35
- const libraryCopies = originalLib[DD_LIB_COPIES]
36
-
37
- if (libraryCopies) {
38
- libraryCopies.forEach(libraryCopy => {
39
- shim.unwrap(libraryCopy.prototype, '_then')
40
- shim.unwrap(libraryCopy, 'getNewLibraryCopy')
41
- })
42
- libraryCopies.clear()
43
- delete originalLib[DD_LIB_COPIES]
44
- }
45
- }
46
-
47
- module.exports = [
48
- {
49
- name: 'bluebird',
50
- versions: ['^2.11.0', '^3.4.1'],
51
- patch (Promise, tracer, config) {
52
- this.wrap(Promise, 'getNewLibraryCopy', createGetNewLibraryCopyWrap(tracer, config, Promise, this))
53
- },
54
- unpatch (Promise) {
55
- this.unwrap(Promise, 'getNewLibraryCopy')
56
- unwrapLibraryCopies(Promise, this)
57
- }
58
- },
59
- {
60
- name: 'bluebird',
61
- versions: ['>=2.0.2'], // 2.0.0 and 2.0.1 were removed from npm
62
- patch (Promise, tracer, config) {
63
- this.wrap(Promise.prototype, '_then', tx.createWrapThen(tracer, config))
64
- },
65
- unpatch (Promise) {
66
- this.unwrap(Promise.prototype, '_then')
67
- }
68
- }
69
- ]
@@ -1,17 +0,0 @@
1
- 'use strict'
2
-
3
- const tx = require('../../dd-trace/src/plugins/util/promise')
4
-
5
- module.exports = [
6
- {
7
- name: 'promise',
8
- file: 'lib/core.js',
9
- versions: ['>=7'],
10
- patch (Promise, tracer, config) {
11
- this.wrap(Promise.prototype, 'then', tx.createWrapThen(tracer, config))
12
- },
13
- unpatch (Promise) {
14
- this.unwrap(Promise.prototype, 'then')
15
- }
16
- }
17
- ]
@@ -1,20 +0,0 @@
1
- 'use strict'
2
-
3
- const tx = require('../../dd-trace/src/plugins/util/promise')
4
-
5
- module.exports = [
6
- {
7
- name: 'promise-js',
8
- versions: ['>=0.0.3'],
9
- patch (Promise, tracer, config) {
10
- if (Promise !== global.Promise) {
11
- this.wrap(Promise.prototype, 'then', tx.createWrapThen(tracer, config))
12
- }
13
- },
14
- unpatch (Promise) {
15
- if (Promise !== global.Promise) {
16
- this.unwrap(Promise.prototype, 'then')
17
- }
18
- }
19
- }
20
- ]
@@ -1,16 +0,0 @@
1
- 'use strict'
2
-
3
- const tx = require('../../dd-trace/src/plugins/util/promise')
4
-
5
- module.exports = [
6
- {
7
- name: 'q',
8
- versions: ['>=1'],
9
- patch (Q, tracer, config) {
10
- this.wrap(Q.makePromise.prototype, 'then', tx.createWrapThen(tracer, config))
11
- },
12
- unpatch (Q) {
13
- this.unwrap(Q.makePromise.prototype, 'then')
14
- }
15
- }
16
- ]
@@ -1,17 +0,0 @@
1
- 'use strict'
2
-
3
- const tx = require('../../dd-trace/src/plugins/util/promise')
4
-
5
- module.exports = [
6
- {
7
- name: 'when',
8
- file: 'lib/Promise.js',
9
- versions: ['>=3'],
10
- patch (Promise, tracer, config) {
11
- this.wrap(Promise.prototype, 'then', tx.createWrapThen(tracer, config))
12
- },
13
- unpatch (Promise) {
14
- this.unwrap(Promise.prototype, 'then')
15
- }
16
- }
17
- ]
@@ -1,8 +0,0 @@
1
- 'use strict'
2
-
3
- const dc = require('diagnostics_channel')
4
-
5
- module.exports = {
6
- INCOMING_HTTP_REQUEST_START: dc.channel('dd-trace:INCOMING_HTTP_REQUEST_START'),
7
- INCOMING_HTTP_REQUEST_END: dc.channel('dd-trace:INCOMING_HTTP_REQUEST_END')
8
- }
@@ -1,68 +0,0 @@
1
- 'use strict'
2
-
3
- const dc = require('diagnostics_channel')
4
- const shimmer = require('shimmer')
5
-
6
- let protoCache
7
-
8
- function getActiveChannelPrototype () {
9
- if (protoCache) return protoCache
10
-
11
- const noop = () => {}
12
-
13
- const channel = dc.channel('dd-trace:temp_getproto')
14
-
15
- // We have to force the channel to switch to ActiveChannel prototype
16
- channel.subscribe(noop)
17
-
18
- const activeChannelPrototype = Object.getPrototypeOf(channel)
19
-
20
- channel.unsubscribe(noop)
21
-
22
- protoCache = activeChannelPrototype
23
-
24
- return activeChannelPrototype
25
- }
26
-
27
- function blockingPublish (data) {
28
- let firstError
29
-
30
- for (let i = 0; i < this._subscribers.length; i++) {
31
- try {
32
- const onMessage = this._subscribers[i]
33
- onMessage(data, this.name)
34
- } catch (err) {
35
- if (firstError === undefined && err instanceof DCBlockingError) {
36
- firstError = err
37
- } else {
38
- process.nextTick(() => {
39
- throw err
40
- })
41
- }
42
- }
43
- }
44
-
45
- if (firstError) throw firstError
46
- }
47
-
48
- function enable () {
49
- shimmer.wrap(getActiveChannelPrototype(), 'publish', (originalPublish) => {
50
- return blockingPublish
51
- })
52
- }
53
-
54
- function disable () {
55
- shimmer.unwrap(getActiveChannelPrototype(), 'publish')
56
- }
57
-
58
- class DCBlockingError extends Error {
59
- get name () {
60
- return this.constructor.name
61
- }
62
- }
63
-
64
- module.exports = {
65
- enable,
66
- disable,
67
- DCBlockingError
68
- }
@@ -1,36 +0,0 @@
1
- [
2
- "test.type",
3
- "test.status",
4
- "test.framework",
5
- "test.framework_version",
6
- "test.suite",
7
- "test.name",
8
- "test.skip_reason",
9
- "ci.pipeline.id",
10
- "ci.pipeline.name",
11
- "ci.pipeline.number",
12
- "ci.pipeline.url",
13
- "ci.provider.name",
14
- "ci.workspace_path",
15
- "git.repository_url",
16
- "ci.job.url",
17
- "ci.job.name",
18
- "ci.stage.name",
19
- "git.commit.sha",
20
- "git.branch",
21
- "git.tag",
22
- "git.commit.message",
23
- "git.commit.committer.date",
24
- "git.commit.committer.email",
25
- "git.commit.committer.name",
26
- "git.commit.author.date",
27
- "git.commit.author.email",
28
- "git.commit.author.name",
29
- "os.platform",
30
- "os.version",
31
- "os.architecture",
32
- "runtime.name",
33
- "runtime.version",
34
- "test.parameters",
35
- "_dd.origin"
36
- ]
@@ -1,31 +0,0 @@
1
- 'use strict'
2
-
3
- module.exports = {
4
- createWrapThen (tracer, config) {
5
- return function wrapThen (then) {
6
- return function thenWithTrace (onFulfilled, onRejected, onProgress) {
7
- arguments[0] = wrapCallback(tracer, onFulfilled)
8
- arguments[1] = wrapCallback(tracer, onRejected)
9
-
10
- // not standard but sometimes supported
11
- if (onProgress) {
12
- arguments[2] = wrapCallback(tracer, onProgress)
13
- }
14
-
15
- return then.apply(this, arguments)
16
- }
17
- }
18
- }
19
- }
20
-
21
- function wrapCallback (tracer, callback) {
22
- if (typeof callback !== 'function') return callback
23
-
24
- const span = tracer.scope().active()
25
-
26
- return function () {
27
- return tracer.scope().activate(span, () => {
28
- return callback.apply(this, arguments)
29
- })
30
- }
31
- }
@@ -1,28 +0,0 @@
1
- 'use strict'
2
-
3
- const Span = require('opentracing').Span
4
- const Scope = require('./scope')
5
-
6
- let singleton = null
7
-
8
- const span = new Span()
9
-
10
- class ScopeManager {
11
- constructor () {
12
- if (!singleton) {
13
- singleton = this
14
- }
15
-
16
- return singleton
17
- }
18
-
19
- active () {
20
- return new Scope(span)
21
- }
22
-
23
- activate (span, finishSpanOnClose) {
24
- return new Scope(span, finishSpanOnClose)
25
- }
26
- }
27
-
28
- module.exports = ScopeManager