dd-trace 5.57.1 → 5.59.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 (206) hide show
  1. package/LICENSE-3rdparty.csv +3 -1
  2. package/ci/cypress/after-run.js +2 -0
  3. package/ci/cypress/after-spec.js +2 -0
  4. package/ci/cypress/plugin.js +2 -0
  5. package/ci/cypress/polyfills.js +2 -0
  6. package/ci/cypress/support.js +2 -0
  7. package/ci/init.js +2 -0
  8. package/index.d.ts +7 -0
  9. package/init.js +1 -6
  10. package/initialize.mjs +2 -0
  11. package/package.json +40 -9
  12. package/packages/datadog-code-origin/index.js +14 -9
  13. package/packages/datadog-instrumentations/src/apollo.js +7 -10
  14. package/packages/datadog-instrumentations/src/avsc.js +2 -0
  15. package/packages/datadog-instrumentations/src/azure-functions.js +1 -1
  16. package/packages/datadog-instrumentations/src/child_process.js +22 -43
  17. package/packages/datadog-instrumentations/src/cucumber.js +10 -8
  18. package/packages/datadog-instrumentations/src/cypress.js +2 -0
  19. package/packages/datadog-instrumentations/src/fastify.js +19 -1
  20. package/packages/datadog-instrumentations/src/graphql.js +9 -0
  21. package/packages/datadog-instrumentations/src/helpers/hooks.js +1 -0
  22. package/packages/datadog-instrumentations/src/helpers/register.js +2 -2
  23. package/packages/datadog-instrumentations/src/hono.js +102 -0
  24. package/packages/datadog-instrumentations/src/jest.js +1 -1
  25. package/packages/datadog-instrumentations/src/langchain.js +21 -0
  26. package/packages/datadog-instrumentations/src/mocha/common.js +2 -0
  27. package/packages/datadog-instrumentations/src/mocha.js +2 -0
  28. package/packages/datadog-instrumentations/src/mysql2.js +6 -6
  29. package/packages/datadog-instrumentations/src/next.js +3 -1
  30. package/packages/datadog-instrumentations/src/nyc.js +2 -0
  31. package/packages/datadog-instrumentations/src/oracledb.js +24 -2
  32. package/packages/datadog-instrumentations/src/orchestrion-config/index.js +32 -0
  33. package/packages/datadog-instrumentations/src/playwright.js +5 -1
  34. package/packages/datadog-instrumentations/src/protobufjs.js +2 -0
  35. package/packages/datadog-instrumentations/src/selenium.js +2 -0
  36. package/packages/datadog-instrumentations/src/tedious.js +12 -17
  37. package/packages/datadog-instrumentations/src/vitest.js +2 -0
  38. package/packages/datadog-plugin-avsc/src/index.js +2 -0
  39. package/packages/datadog-plugin-avsc/src/schema_iterator.js +2 -0
  40. package/packages/datadog-plugin-aws-sdk/src/base.js +51 -1
  41. package/packages/datadog-plugin-aws-sdk/src/services/bedrockruntime/index.js +2 -0
  42. package/packages/datadog-plugin-child_process/src/index.js +30 -10
  43. package/packages/datadog-plugin-child_process/src/scrub-cmd-params.js +1 -1
  44. package/packages/datadog-plugin-cypress/src/after-run.js +2 -0
  45. package/packages/datadog-plugin-cypress/src/after-spec.js +2 -0
  46. package/packages/datadog-plugin-cypress/src/cypress-plugin.js +8 -3
  47. package/packages/datadog-plugin-cypress/src/index.js +2 -0
  48. package/packages/datadog-plugin-cypress/src/plugin.js +2 -0
  49. package/packages/datadog-plugin-cypress/src/support.js +21 -25
  50. package/packages/datadog-plugin-google-cloud-vertexai/src/utils.js +2 -0
  51. package/packages/datadog-plugin-graphql/src/tools/index.js +0 -2
  52. package/packages/datadog-plugin-graphql/src/tools/signature.js +0 -2
  53. package/packages/datadog-plugin-graphql/src/tools/transforms.js +0 -2
  54. package/packages/datadog-plugin-graphql/src/utils.js +2 -0
  55. package/packages/datadog-plugin-hono/src/index.js +28 -0
  56. package/packages/datadog-plugin-http/src/client.js +3 -4
  57. package/packages/datadog-plugin-http2/src/client.js +9 -8
  58. package/packages/datadog-plugin-jest/src/index.js +2 -0
  59. package/packages/datadog-plugin-jest/src/util.js +2 -0
  60. package/packages/datadog-plugin-kafkajs/src/batch-consumer.js +2 -0
  61. package/packages/datadog-plugin-langchain/src/handlers/chain.js +1 -1
  62. package/packages/datadog-plugin-langchain/src/handlers/language_models/chat_model.js +1 -1
  63. package/packages/datadog-plugin-langchain/src/handlers/language_models/llm.js +1 -1
  64. package/packages/datadog-plugin-langchain/src/tracing.js +36 -4
  65. package/packages/datadog-plugin-nyc/src/index.js +2 -0
  66. package/packages/datadog-plugin-oracledb/src/connection-parser.js +37 -0
  67. package/packages/datadog-plugin-oracledb/src/index.js +15 -17
  68. package/packages/datadog-plugin-protobufjs/src/index.js +2 -0
  69. package/packages/datadog-plugin-protobufjs/src/schema_iterator.js +2 -0
  70. package/packages/datadog-plugin-selenium/src/index.js +2 -0
  71. package/packages/datadog-plugin-tedious/src/index.js +10 -9
  72. package/packages/datadog-plugin-vitest/src/index.js +2 -0
  73. package/packages/dd-trace/src/appsec/iast/analyzers/injection-analyzer.js +6 -4
  74. package/packages/dd-trace/src/appsec/iast/analyzers/ssrf-analyzer.js +9 -0
  75. package/packages/dd-trace/src/appsec/iast/iast-context.js +5 -1
  76. package/packages/dd-trace/src/appsec/iast/index.js +2 -0
  77. package/packages/dd-trace/src/appsec/iast/overhead-controller.js +1 -1
  78. package/packages/dd-trace/src/appsec/iast/taint-tracking/operations-taint-object.js +5 -2
  79. package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter-esm.mjs +0 -2
  80. package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter.js +2 -0
  81. package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-regex.js +2 -0
  82. package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/index.js +1 -0
  83. package/packages/dd-trace/src/appsec/iast/vulnerabilities.js +2 -0
  84. package/packages/dd-trace/src/appsec/iast/vulnerability-reporter.js +3 -3
  85. package/packages/dd-trace/src/appsec/rasp/fs-plugin.js +18 -11
  86. package/packages/dd-trace/src/appsec/rasp/utils.js +1 -1
  87. package/packages/dd-trace/src/appsec/recommended.json +88 -2
  88. package/packages/dd-trace/src/appsec/reporter.js +68 -14
  89. package/packages/dd-trace/src/appsec/rule_manager.js +63 -171
  90. package/packages/dd-trace/src/appsec/sdk/track_event.js +3 -5
  91. package/packages/dd-trace/src/appsec/stack_trace.js +11 -11
  92. package/packages/dd-trace/src/appsec/telemetry/common.js +2 -2
  93. package/packages/dd-trace/src/appsec/telemetry/index.js +8 -0
  94. package/packages/dd-trace/src/appsec/telemetry/waf.js +5 -3
  95. package/packages/dd-trace/src/appsec/waf/diagnostics.js +15 -0
  96. package/packages/dd-trace/src/appsec/waf/index.js +47 -6
  97. package/packages/dd-trace/src/appsec/waf/waf_context_wrapper.js +2 -2
  98. package/packages/dd-trace/src/appsec/waf/waf_manager.js +22 -12
  99. package/packages/dd-trace/src/ci-visibility/dynamic-instrumentation/index.js +3 -3
  100. package/packages/dd-trace/src/ci-visibility/early-flake-detection/get-known-tests.js +2 -0
  101. package/packages/dd-trace/src/ci-visibility/exporters/git/git_metadata.js +3 -1
  102. package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +2 -0
  103. package/packages/dd-trace/src/ci-visibility/log-submission/log-submission-plugin.js +2 -0
  104. package/packages/dd-trace/src/ci-visibility/requests/get-library-configuration.js +2 -0
  105. package/packages/dd-trace/src/ci-visibility/telemetry.js +2 -0
  106. package/packages/dd-trace/src/ci-visibility/test-api-manual/test-api-manual-plugin.js +2 -0
  107. package/packages/dd-trace/src/ci-visibility/test-management/get-test-management-tests.js +7 -3
  108. package/packages/dd-trace/src/config.js +15 -4
  109. package/packages/dd-trace/src/config_stable.js +2 -0
  110. package/packages/dd-trace/src/constants.js +1 -2
  111. package/packages/dd-trace/src/datastreams/checkpointer.js +2 -0
  112. package/packages/dd-trace/src/datastreams/context.js +2 -0
  113. package/packages/dd-trace/src/datastreams/encoding.js +2 -0
  114. package/packages/dd-trace/src/datastreams/fnv.js +2 -0
  115. package/packages/dd-trace/src/datastreams/pathway.js +11 -9
  116. package/packages/dd-trace/src/datastreams/processor.js +8 -7
  117. package/packages/dd-trace/src/datastreams/schemas/schema.js +2 -0
  118. package/packages/dd-trace/src/datastreams/schemas/schema_builder.js +45 -36
  119. package/packages/dd-trace/src/datastreams/schemas/schema_sampler.js +2 -0
  120. package/packages/dd-trace/src/datastreams/writer.js +2 -0
  121. package/packages/dd-trace/src/debugger/devtools_client/index.js +12 -4
  122. package/packages/dd-trace/src/debugger/devtools_client/inspector_promises_polyfill.js +2 -0
  123. package/packages/dd-trace/src/debugger/devtools_client/remote_config.js +8 -5
  124. package/packages/dd-trace/src/debugger/devtools_client/snapshot/symbols.js +1 -1
  125. package/packages/dd-trace/src/debugger/index.js +36 -9
  126. package/packages/dd-trace/src/encode/tags-processors.js +2 -0
  127. package/packages/dd-trace/src/exporters/common/agent-info-exporter.js +2 -0
  128. package/packages/dd-trace/src/exporters/common/request.js +1 -1
  129. package/packages/dd-trace/src/exporters/common/util.js +2 -0
  130. package/packages/dd-trace/src/exporters/span-stats/index.js +2 -0
  131. package/packages/dd-trace/src/exporters/span-stats/writer.js +2 -0
  132. package/packages/dd-trace/src/external-logger/src/index.js +2 -0
  133. package/packages/dd-trace/src/git_metadata_tagger.js +2 -0
  134. package/packages/dd-trace/src/git_properties.js +2 -0
  135. package/packages/dd-trace/src/guardrails/index.js +3 -4
  136. package/packages/dd-trace/src/guardrails/log.js +2 -2
  137. package/packages/dd-trace/src/guardrails/telemetry.js +16 -14
  138. package/packages/dd-trace/src/guardrails/util.js +0 -2
  139. package/packages/dd-trace/src/heap_snapshots.js +58 -0
  140. package/packages/dd-trace/src/llmobs/noop.js +1 -1
  141. package/packages/dd-trace/src/llmobs/plugins/bedrockruntime.js +2 -0
  142. package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/index.js +5 -0
  143. package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/tool.js +15 -0
  144. package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/vectorstore.js +36 -0
  145. package/packages/dd-trace/src/llmobs/plugins/langchain/index.js +47 -4
  146. package/packages/dd-trace/src/llmobs/span_processor.js +1 -1
  147. package/packages/dd-trace/src/llmobs/tagger.js +10 -1
  148. package/packages/dd-trace/src/log/log.js +1 -1
  149. package/packages/dd-trace/src/noop/dogstatsd.js +2 -0
  150. package/packages/dd-trace/src/opentracing/propagation/text_map_dsm.js +2 -0
  151. package/packages/dd-trace/src/opentracing/span.js +1 -1
  152. package/packages/dd-trace/src/payload-tagging/config/index.js +2 -0
  153. package/packages/dd-trace/src/payload-tagging/index.js +3 -1
  154. package/packages/dd-trace/src/payload-tagging/tagging.js +4 -2
  155. package/packages/dd-trace/src/plugins/apollo.js +2 -0
  156. package/packages/dd-trace/src/plugins/ci_plugin.js +8 -3
  157. package/packages/dd-trace/src/plugins/index.js +1 -0
  158. package/packages/dd-trace/src/plugins/outbound.js +7 -0
  159. package/packages/dd-trace/src/plugins/util/ci.js +2 -0
  160. package/packages/dd-trace/src/plugins/util/env.js +2 -0
  161. package/packages/dd-trace/src/plugins/util/git.js +40 -5
  162. package/packages/dd-trace/src/plugins/util/inferred_proxy.js +2 -0
  163. package/packages/dd-trace/src/plugins/util/llm.js +2 -0
  164. package/packages/dd-trace/src/plugins/util/serverless.js +2 -0
  165. package/packages/dd-trace/src/plugins/util/stacktrace.js +178 -50
  166. package/packages/dd-trace/src/plugins/util/tags.js +17 -1
  167. package/packages/dd-trace/src/plugins/util/test.js +9 -4
  168. package/packages/dd-trace/src/plugins/util/url.js +2 -0
  169. package/packages/dd-trace/src/plugins/util/user-provided-git.js +2 -0
  170. package/packages/dd-trace/src/profiling/exporters/event_serializer.js +4 -0
  171. package/packages/dd-trace/src/profiling/profiler.js +89 -70
  172. package/packages/dd-trace/src/profiling/profilers/event_plugins/dns.js +2 -0
  173. package/packages/dd-trace/src/profiling/profilers/event_plugins/dns_lookup.js +2 -0
  174. package/packages/dd-trace/src/profiling/profilers/event_plugins/dns_lookupservice.js +2 -0
  175. package/packages/dd-trace/src/profiling/profilers/event_plugins/dns_resolve.js +2 -0
  176. package/packages/dd-trace/src/profiling/profilers/event_plugins/dns_reverse.js +2 -0
  177. package/packages/dd-trace/src/profiling/profilers/event_plugins/event.js +2 -0
  178. package/packages/dd-trace/src/profiling/profilers/event_plugins/fs.js +2 -0
  179. package/packages/dd-trace/src/profiling/profilers/event_plugins/net.js +2 -0
  180. package/packages/dd-trace/src/profiling/profilers/events.js +2 -0
  181. package/packages/dd-trace/src/profiling/profilers/wall.js +2 -2
  182. package/packages/dd-trace/src/profiling/webspan-utils.js +2 -0
  183. package/packages/dd-trace/src/proxy.js +4 -0
  184. package/packages/dd-trace/src/remote_config/capabilities.js +3 -1
  185. package/packages/dd-trace/src/remote_config/index.js +4 -0
  186. package/packages/dd-trace/src/service-naming/index.js +2 -0
  187. package/packages/dd-trace/src/service-naming/schemas/definition.js +4 -9
  188. package/packages/dd-trace/src/service-naming/schemas/util.js +2 -0
  189. package/packages/dd-trace/src/service-naming/schemas/v0/graphql.js +2 -0
  190. package/packages/dd-trace/src/service-naming/schemas/v0/index.js +2 -0
  191. package/packages/dd-trace/src/service-naming/schemas/v0/messaging.js +2 -0
  192. package/packages/dd-trace/src/service-naming/schemas/v0/serverless.js +2 -0
  193. package/packages/dd-trace/src/service-naming/schemas/v0/storage.js +2 -0
  194. package/packages/dd-trace/src/service-naming/schemas/v0/web.js +2 -0
  195. package/packages/dd-trace/src/service-naming/schemas/v1/graphql.js +2 -0
  196. package/packages/dd-trace/src/service-naming/schemas/v1/index.js +2 -0
  197. package/packages/dd-trace/src/service-naming/schemas/v1/messaging.js +2 -0
  198. package/packages/dd-trace/src/service-naming/schemas/v1/serverless.js +2 -0
  199. package/packages/dd-trace/src/service-naming/schemas/v1/storage.js +4 -1
  200. package/packages/dd-trace/src/service-naming/schemas/v1/web.js +2 -0
  201. package/packages/dd-trace/src/span_stats.js +2 -0
  202. package/packages/dd-trace/src/supported-configurations.json +5 -0
  203. package/packages/dd-trace/src/telemetry/send-data.js +2 -0
  204. package/register.js +4 -0
  205. package/version.js +0 -3
  206. package/packages/dd-trace/src/payload-tagging/jsonpath-plus.js +0 -2094
@@ -1,5 +1,5 @@
1
- /* eslint-disable unicorn/no-abusive-eslint-disable */
2
- /* eslint-disable */
1
+ 'use strict'
2
+
3
3
  let isEarlyFlakeDetectionEnabled = false
4
4
  let isKnownTestsEnabled = false
5
5
  let knownTestsForSuite = []
@@ -20,7 +20,7 @@ let originalWindow
20
20
  function safeGetRum (window) {
21
21
  try {
22
22
  return window.DD_RUM
23
- } catch (e) {
23
+ } catch {
24
24
  return null
25
25
  }
26
26
  }
@@ -30,12 +30,13 @@ function isNewTest (test) {
30
30
  }
31
31
 
32
32
  function getTestProperties (testName) {
33
- // We neeed to do it in this way because of compatibility with older versions as '?' is not supported in older versions of Cypress
34
- const properties = testManagementTests[testName] && testManagementTests[testName].properties || {};
33
+ // TODO: Use optional chaining when we drop support for older Cypress versions, which will happen when dd-trace@5 is
34
+ // EoL. Until then, this files needs to support Node.js 16.
35
+ const properties = testManagementTests[testName] && testManagementTests[testName].properties || {}
35
36
 
36
- const { attempt_to_fix: isAttemptToFix, disabled: isDisabled, quarantined: isQuarantined } = properties;
37
+ const { attempt_to_fix: isAttemptToFix, disabled: isDisabled, quarantined: isQuarantined } = properties
37
38
 
38
- return { isAttemptToFix, isDisabled, isQuarantined };
39
+ return { isAttemptToFix, isDisabled, isQuarantined }
39
40
  }
40
41
 
41
42
  function retryTest (test, suiteTests, numRetries, tags) {
@@ -63,11 +64,9 @@ Cypress.mocha.getRunner().runTests = function (suite, fn) {
63
64
 
64
65
  const { isAttemptToFix } = getTestProperties(testName)
65
66
 
66
- if (isTestManagementEnabled) {
67
- if (isAttemptToFix && !test.isPending()) {
68
- test._ddIsAttemptToFix = true
69
- retryTest(test, suite.tests, testManagementAttemptToFixRetries, ['_ddIsAttemptToFix'])
70
- }
67
+ if (isTestManagementEnabled && isAttemptToFix && !test.isPending()) {
68
+ test._ddIsAttemptToFix = true
69
+ retryTest(test, suite.tests, testManagementAttemptToFixRetries, ['_ddIsAttemptToFix'])
71
70
  }
72
71
  if (isImpactedTestsEnabled && isModifiedTest) {
73
72
  test._ddIsModified = true
@@ -80,15 +79,13 @@ Cypress.mocha.getRunner().runTests = function (suite, fn) {
80
79
  )
81
80
  }
82
81
  }
83
- if (isKnownTestsEnabled) {
84
- if (!test._ddIsNew && !test.isPending() && isNewTest(test)) {
85
- test._ddIsNew = true
86
- if (isImpactedTestsEnabled && isModifiedTest) {
87
- test._ddIsModified = true
88
- }
89
- if (isEarlyFlakeDetectionEnabled && !isAttemptToFix && !isModifiedTest) {
90
- retryTest(test, suite.tests, earlyFlakeDetectionNumRetries, ['_ddIsNew', '_ddIsEfdRetry'])
91
- }
82
+ if (isKnownTestsEnabled && !test._ddIsNew && !test.isPending() && isNewTest(test)) {
83
+ test._ddIsNew = true
84
+ if (isImpactedTestsEnabled && isModifiedTest) {
85
+ test._ddIsModified = true
86
+ }
87
+ if (isEarlyFlakeDetectionEnabled && !isAttemptToFix && !isModifiedTest) {
88
+ retryTest(test, suite.tests, earlyFlakeDetectionNumRetries, ['_ddIsNew', '_ddIsEfdRetry'])
92
89
  }
93
90
  }
94
91
  })
@@ -135,12 +132,11 @@ after(() => {
135
132
  if (safeGetRum(originalWindow)) {
136
133
  originalWindow.dispatchEvent(new Event('beforeunload'))
137
134
  }
138
- } catch (e) {
135
+ } catch {
139
136
  // ignore error. It's usually a multi origin issue.
140
137
  }
141
138
  })
142
139
 
143
-
144
140
  afterEach(function () {
145
141
  const currentTest = Cypress.mocha.getRunner().suite.ctx.currentTest
146
142
  const testInfo = {
@@ -156,7 +152,7 @@ afterEach(function () {
156
152
  }
157
153
  try {
158
154
  testInfo.testSourceLine = Cypress.mocha.getRunner().currentRunnable.invocationDetails.line
159
- } catch (e) {}
155
+ } catch {}
160
156
 
161
157
  if (safeGetRum(originalWindow)) {
162
158
  testInfo.isRUMActive = true
@@ -164,7 +160,7 @@ afterEach(function () {
164
160
  let coverage
165
161
  try {
166
162
  coverage = originalWindow.__coverage__
167
- } catch (e) {
163
+ } catch {
168
164
  // ignore error and continue
169
165
  }
170
166
  cy.task('dd:afterEach', { test: testInfo, coverage })
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  function extractModel (instance) {
2
4
  const model = instance.model || instance.resourcePath || instance.publisherModelEndpoint
3
5
  return model?.split('/').pop()
@@ -1,5 +1,3 @@
1
- /* eslint-disable unicorn/no-abusive-eslint-disable */
2
- /* eslint-disable */
3
1
  // file mostly untouched from apollo-graphql
4
2
 
5
3
  "use strict";
@@ -1,5 +1,3 @@
1
- /* eslint-disable unicorn/no-abusive-eslint-disable */
2
- /* eslint-disable */
3
1
  // file mostly untouched from apollo-graphql
4
2
 
5
3
  "use strict";
@@ -1,5 +1,3 @@
1
- /* eslint-disable unicorn/no-abusive-eslint-disable */
2
- /* eslint-disable */
3
1
  // file mostly untouched from apollo-graphql
4
2
 
5
3
  "use strict";
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  function extractErrorIntoSpanEvent (config, span, exc) {
2
4
  const attributes = {}
3
5
 
@@ -0,0 +1,28 @@
1
+ 'use strict'
2
+
3
+ const RouterPlugin = require('../../datadog-plugin-router/src')
4
+ const web = require('../../dd-trace/src/plugins/util/web')
5
+
6
+ class HonoPlugin extends RouterPlugin {
7
+ static get id () {
8
+ return 'hono'
9
+ }
10
+
11
+ constructor (...args) {
12
+ super(...args)
13
+
14
+ this.addSub('apm:hono:request:handle', ({ req }) => {
15
+ this.setFramework(req, 'hono', this.config)
16
+ })
17
+
18
+ this.addSub('apm:hono:request:route', ({ req, route }) => {
19
+ web.setRoute(req, route)
20
+ })
21
+
22
+ this.addSub('apm:hono:request:error', ({ req, error }) => {
23
+ web.addError(req, error)
24
+ })
25
+ }
26
+ }
27
+
28
+ module.exports = HonoPlugin
@@ -89,7 +89,8 @@ class HttpClientPlugin extends ClientPlugin {
89
89
  return parentStore
90
90
  }
91
91
 
92
- finish ({ req, res, span }) {
92
+ finish (ctx) {
93
+ const { req, res, span } = ctx
93
94
  if (!span) return
94
95
  if (res) {
95
96
  const status = res.status || res.statusCode
@@ -109,9 +110,7 @@ class HttpClientPlugin extends ClientPlugin {
109
110
 
110
111
  this.config.hooks.request(span, req, res)
111
112
 
112
- this.tagPeerService(span)
113
-
114
- span.finish()
113
+ super.finish(ctx)
115
114
  }
116
115
 
117
116
  error ({ span, error, args, customRequestTimeout }) {
@@ -73,7 +73,9 @@ class Http2ClientPlugin extends ClientPlugin {
73
73
  return message.currentStore
74
74
  }
75
75
 
76
- bindAsyncStart ({ eventName, eventData, currentStore, parentStore }) {
76
+ bindAsyncStart (ctx) {
77
+ const { eventName, eventData, currentStore, parentStore } = ctx
78
+
77
79
  // Plugin wasn't enabled when the request started.
78
80
  if (!currentStore) return storage('legacy').getStore()
79
81
 
@@ -82,10 +84,10 @@ class Http2ClientPlugin extends ClientPlugin {
82
84
  this._onResponse(currentStore, eventData)
83
85
  return parentStore
84
86
  case 'error':
85
- this._onError(currentStore, eventData)
87
+ this._onError(currentStore, eventData, ctx)
86
88
  return parentStore
87
89
  case 'close':
88
- this._onClose(currentStore, eventData)
90
+ this._onClose(ctx)
89
91
  return parentStore
90
92
  }
91
93
 
@@ -108,14 +110,13 @@ class Http2ClientPlugin extends ClientPlugin {
108
110
  addHeaderTags(store.span, headers, HTTP_RESPONSE_HEADERS, this.config)
109
111
  }
110
112
 
111
- _onError ({ span }, error) {
113
+ _onError ({ span }, error, ctx) {
112
114
  span.setTag('error', error)
113
- span.finish()
115
+ super.finish(ctx)
114
116
  }
115
117
 
116
- _onClose ({ span }) {
117
- this.tagPeerService(span)
118
- span.finish()
118
+ _onClose (ctx) {
119
+ super.finish(ctx)
119
120
  }
120
121
  }
121
122
 
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  const CiPlugin = require('../../dd-trace/src/plugins/ci_plugin')
2
4
  const { storage } = require('../../datadog-core')
3
5
  const { getEnvironmentVariable } = require('../../dd-trace/src/config-helper')
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  const { readFileSync } = require('fs')
2
4
  const { parse, extract } = require('jest-docblock')
3
5
 
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  const ConsumerPlugin = require('../../dd-trace/src/plugins/consumer')
2
4
  const { getMessageSize } = require('../../dd-trace/src/datastreams')
3
5
  const { convertToTextMap } = require('./utils')
@@ -13,7 +13,7 @@ class LangChainChainHandler extends LangChainHandler {
13
13
 
14
14
  for (const idx in inputs) {
15
15
  const input = inputs[idx]
16
- if (typeof input === 'object') {
16
+ if (input !== null && typeof input === 'object') {
17
17
  for (const [key, value] of Object.entries(input)) {
18
18
  // these are mappings to the python client names, ie lc_kwargs
19
19
  // only present on BaseMessage types
@@ -27,7 +27,7 @@ class LangChainChatModelHandler extends LangChainLanguageModelHandler {
27
27
  const identifyingParams = (typeof instance._identifyingParams === 'function' && instance._identifyingParams()) || {}
28
28
  for (const [param, val] of Object.entries(identifyingParams)) {
29
29
  if (param.toLowerCase().includes('apikey') || param.toLowerCase().includes('apitoken')) continue
30
- if (typeof val === 'object') {
30
+ if (val !== null && typeof val === 'object') {
31
31
  for (const [key, value] of Object.entries(val)) {
32
32
  tags[`langchain.request.${provider}.parameters.${param}.${key}`] = value
33
33
  }
@@ -18,7 +18,7 @@ class LangChainLLMHandler extends LangChainLanguageModelHandler {
18
18
  const identifyingParams = (typeof instance._identifyingParams === 'function' && instance._identifyingParams()) || {}
19
19
  for (const [param, val] of Object.entries(identifyingParams)) {
20
20
  if (param.toLowerCase().includes('apikey') || param.toLowerCase().includes('apitoken')) continue
21
- if (typeof val === 'object') {
21
+ if (val !== null && typeof val === 'object') {
22
22
  for (const [key, value] of Object.entries(val)) {
23
23
  tags[`langchain.request.${provider}.parameters.${param}.${key}`] = value
24
24
  }
@@ -40,9 +40,14 @@ class BaseLangChainTracingPlugin extends TracingPlugin {
40
40
 
41
41
  // Runnable interfaces have an `lc_namespace` property
42
42
  const ns = ctx.self.lc_namespace || ctx.namespace
43
- const resource = ctx.resource = [...ns, ctx.self.constructor.name].join('.')
44
43
 
45
- const handler = this.handlers[type]
44
+ const resourceParts = [...ns, ctx.self.constructor.name]
45
+ if (type === 'tool') {
46
+ resourceParts.push(ctx.instance.name)
47
+ }
48
+ const resource = ctx.resource = resourceParts.join('.')
49
+
50
+ const handler = this.handlers[type] || this.handlers.default
46
51
 
47
52
  const instance = ctx.instance
48
53
  const apiKey = handler.extractApiKey(instance)
@@ -78,7 +83,7 @@ class BaseLangChainTracingPlugin extends TracingPlugin {
78
83
 
79
84
  const { type } = ctx
80
85
 
81
- const handler = this.handlers[type]
86
+ const handler = this.handlers[type] || this.handlers.default
82
87
  const tags = handler.getSpanEndTags(ctx, span) || {}
83
88
 
84
89
  span.addTags(tags)
@@ -139,11 +144,38 @@ class EmbeddingsEmbedDocumentsPlugin extends BaseLangChainTracingPlugin {
139
144
  }
140
145
  }
141
146
 
147
+ class ToolInvokePlugin extends BaseLangChainTracingPlugin {
148
+ static get id () { return 'langchain_tool_invoke' }
149
+ static get lcType () { return 'tool' }
150
+ static get prefix () {
151
+ return 'tracing:orchestrion:@langchain/core:Tool_invoke'
152
+ }
153
+ }
154
+
155
+ class VectorStoreSimilaritySearchPlugin extends BaseLangChainTracingPlugin {
156
+ static get id () { return 'langchain_vectorstore_similarity_search' }
157
+ static get lcType () { return 'similarity_search' }
158
+ static get prefix () {
159
+ return 'tracing:orchestrion:@langchain/core:VectorStore_similaritySearch'
160
+ }
161
+ }
162
+
163
+ class VectorStoreSimilaritySearchWithScorePlugin extends BaseLangChainTracingPlugin {
164
+ static get id () { return 'langchain_vectorstore_similarity_search_with_score' }
165
+ static get lcType () { return 'similarity_search' }
166
+ static get prefix () {
167
+ return 'tracing:orchestrion:@langchain/core:VectorStore_similaritySearchWithScore'
168
+ }
169
+ }
170
+
142
171
  module.exports = [
143
172
  RunnableSequenceInvokePlugin,
144
173
  RunnableSequenceBatchPlugin,
145
174
  BaseChatModelGeneratePlugin,
146
175
  BaseLLMGeneratePlugin,
147
176
  EmbeddingsEmbedQueryPlugin,
148
- EmbeddingsEmbedDocumentsPlugin
177
+ EmbeddingsEmbedDocumentsPlugin,
178
+ ToolInvokePlugin,
179
+ VectorStoreSimilaritySearchPlugin,
180
+ VectorStoreSimilaritySearchWithScorePlugin
149
181
  ]
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  const CiPlugin = require('../../dd-trace/src/plugins/ci_plugin')
2
4
 
3
5
  class NycPlugin extends CiPlugin {
@@ -0,0 +1,37 @@
1
+ 'use strict'
2
+
3
+ const { URL } = require('url')
4
+ const log = require('../../dd-trace/src/log')
5
+
6
+ function parseOracleDescriptor (descriptor) {
7
+ const hostnameMatch = descriptor.match(/HOST\s*=\s*([^)]+)/i)
8
+ const hostname = hostnameMatch?.[1] || 'localhost' // Default Oracle hostname
9
+
10
+ const portMatch = descriptor.match(/PORT\s*=\s*([^)]+)/i)
11
+ const port = portMatch?.[1] || '1521' // Default Oracle port
12
+
13
+ const sidMatch = descriptor.match(/SID\s*=\s*([^)]+)/i)
14
+
15
+ const dbInstance = sidMatch?.[1] || descriptor.match(/SERVICE_NAME\s*=\s*([^)]+)/i)?.[1] || 'XEPDB1' // Default Oracle service name
16
+
17
+ return { hostname, port, dbInstance }
18
+ }
19
+
20
+ module.exports = function getDBInformation (connAttrs) {
21
+ // Users can pass either connectString or connectionString
22
+ const connectString = ((connAttrs.connectString || connAttrs.connectionString) ?? '').trim()
23
+ if (connectString.startsWith('(')) {
24
+ return parseOracleDescriptor(connectString)
25
+ }
26
+ try {
27
+ const url = new URL(`oracle://${connectString}`)
28
+ return {
29
+ hostname: url.hostname || 'localhost', // Default Oracle hostname
30
+ port: url.port || '1521', // Default Oracle port
31
+ dbInstance: url.pathname && url.pathname.slice(1) || 'XEPDB1' // Default Oracle service name
32
+ }
33
+ } catch (error) {
34
+ log.error('Invalid oracle connection string', error)
35
+ return {}
36
+ }
37
+ }
@@ -2,17 +2,25 @@
2
2
 
3
3
  const { CLIENT_PORT_KEY } = require('../../dd-trace/src/constants')
4
4
  const DatabasePlugin = require('../../dd-trace/src/plugins/database')
5
- const log = require('../../dd-trace/src/log')
5
+
6
+ let parser
6
7
 
7
8
  class OracledbPlugin extends DatabasePlugin {
8
9
  static get id () { return 'oracledb' }
9
10
  static get system () { return 'oracle' }
10
11
  static get peerServicePrecursors () { return ['db.instance', 'db.hostname'] }
11
12
 
12
- start ({ query, connAttrs }) {
13
+ start ({ query, connAttrs, port, hostname, dbInstance }) {
13
14
  const service = this.serviceName({ pluginConfig: this.config, params: connAttrs })
14
- // Users can pass either connectString or connectionString
15
- const url = getUrl(connAttrs.connectString || connAttrs.connectionString)
15
+
16
+ if (hostname === undefined) {
17
+ // Lazy load for performance. This is not needed in v6 and up
18
+ parser ??= require('./connection-parser')
19
+ const dbInfo = parser(connAttrs)
20
+ hostname = dbInfo.hostname
21
+ port ??= dbInfo.port
22
+ dbInstance ??= dbInfo.dbInstance
23
+ }
16
24
 
17
25
  this.startSpan(this.operationName(), {
18
26
  service,
@@ -21,22 +29,12 @@ class OracledbPlugin extends DatabasePlugin {
21
29
  kind: 'client',
22
30
  meta: {
23
31
  'db.user': this.config.user,
24
- 'db.instance': url.pathname && url.pathname.slice(1),
25
- 'db.hostname': url.hostname,
26
- [CLIENT_PORT_KEY]: url.port
32
+ 'db.instance': dbInstance,
33
+ 'db.hostname': hostname,
34
+ [CLIENT_PORT_KEY]: port,
27
35
  }
28
36
  })
29
37
  }
30
38
  }
31
39
 
32
- // TODO: Avoid creating an error since it's a heavy operation.
33
- function getUrl (connectString) {
34
- try {
35
- return new URL(`http://${connectString}`)
36
- } catch (e) {
37
- log.error('Invalid oracle connection string', e)
38
- return {}
39
- }
40
- }
41
-
42
40
  module.exports = OracledbPlugin
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  const SchemaPlugin = require('../../dd-trace/src/plugins/schema')
2
4
  const SchemaExtractor = require('./schema_iterator')
3
5
 
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  const PROTOBUF = 'protobuf'
2
4
  const {
3
5
  SCHEMA_DEFINITION,
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  const CiPlugin = require('../../dd-trace/src/plugins/ci_plugin')
2
4
  const { storage } = require('../../datadog-core')
3
5
 
@@ -8,27 +8,28 @@ class TediousPlugin extends DatabasePlugin {
8
8
  static get operation () { return 'request' } // TODO: change to match other database plugins
9
9
  static get system () { return 'mssql' }
10
10
 
11
- start (payload) {
11
+ bindStart (ctx) {
12
12
  const service = this.serviceName({ pluginConfig: this.config, system: this.system })
13
13
  const span = this.startSpan(this.operationName(), {
14
14
  service,
15
- resource: payload.queryOrProcedure,
15
+ resource: ctx.queryOrProcedure,
16
16
  type: 'sql',
17
17
  kind: 'client',
18
18
  meta: {
19
19
  'db.type': 'mssql',
20
20
  component: 'tedious',
21
- 'out.host': payload.connectionConfig.server,
22
- [CLIENT_PORT_KEY]: payload.connectionConfig.options.port,
23
- 'db.user': payload.connectionConfig.userName || payload.connectionConfig.authentication.options.userName,
24
- 'db.name': payload.connectionConfig.options.database,
25
- 'db.instance': payload.connectionConfig.options.instanceName
21
+ 'out.host': ctx.connectionConfig.server,
22
+ [CLIENT_PORT_KEY]: ctx.connectionConfig.options.port,
23
+ 'db.user': ctx.connectionConfig.userName || ctx.connectionConfig.authentication.options.userName,
24
+ 'db.name': ctx.connectionConfig.options.database,
25
+ 'db.instance': ctx.connectionConfig.options.instanceName
26
26
  }
27
- })
27
+ }, ctx)
28
28
 
29
29
  // SQL Server includes comments when caching queries
30
30
  // For that reason we allow service mode but not full mode
31
- payload.sql = this.injectDbmQuery(span, payload.queryOrProcedure, service, true)
31
+ ctx.sql = this.injectDbmQuery(span, ctx.queryOrProcedure, service, true)
32
+ return ctx.currentStore
32
33
  }
33
34
  }
34
35
 
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  const CiPlugin = require('../../dd-trace/src/plugins/ci_plugin')
2
4
  const { storage } = require('../../datadog-core')
3
5
  const { getEnvironmentVariable } = require('../../dd-trace/src/config-helper')
@@ -7,7 +7,7 @@ class InjectionAnalyzer extends Analyzer {
7
7
  _isVulnerable (value, iastContext) {
8
8
  let ranges = value && getRanges(iastContext, value)
9
9
  if (ranges?.length > 0) {
10
- ranges = this._filterSecureRanges(ranges)
10
+ ranges = this._filterSecureRanges(ranges, value)
11
11
  if (!ranges?.length) {
12
12
  this._incrementSuppressedMetric(iastContext)
13
13
  }
@@ -27,11 +27,13 @@ class InjectionAnalyzer extends Analyzer {
27
27
  return ranges?.some(range => range.iinfo.type !== SQL_ROW_VALUE)
28
28
  }
29
29
 
30
- _filterSecureRanges (ranges) {
31
- return ranges?.filter(range => !this._isRangeSecure(range))
30
+ _filterSecureRanges (ranges, value) {
31
+ return ranges?.filter(range => !this._isRangeSecure(range, value))
32
32
  }
33
33
 
34
- _isRangeSecure (range) {
34
+ _isRangeSecure (range, _value) {
35
+ // _value is not necessary in this method, but could be used in overridden methods
36
+ // added here for visibility
35
37
  const { secureMarks } = range
36
38
  return (secureMarks & this._secureMark) === this._secureMark
37
39
  }
@@ -23,6 +23,15 @@ class SSRFAnalyzer extends InjectionAnalyzer {
23
23
  }
24
24
  })
25
25
  }
26
+
27
+ _isRangeSecure (range, value) {
28
+ const fragmentIndex = value.indexOf('#')
29
+ if (fragmentIndex !== -1 && range.start >= fragmentIndex) {
30
+ return true
31
+ }
32
+
33
+ return super._isRangeSecure(range, value)
34
+ }
26
35
  }
27
36
 
28
37
  module.exports = new SSRFAnalyzer()
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  const IAST_CONTEXT_KEY = Symbol('_dd.iast.context')
2
4
  const IAST_TRANSACTION_ID = Symbol('_dd.iast.transactionId')
3
5
 
@@ -52,7 +54,9 @@ function cleanIastContext (store, context, iastContext) {
52
54
  context[IAST_CONTEXT_KEY] = null
53
55
  }
54
56
  if (iastContext) {
55
- Object.keys(iastContext).forEach(key => delete iastContext[key])
57
+ if (typeof iastContext === 'object') { // eslint-disable-line eslint-rules/eslint-safe-typeof-object
58
+ Object.keys(iastContext).forEach(key => delete iastContext[key])
59
+ }
56
60
  return true
57
61
  }
58
62
  return false
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  const vulnerabilityReporter = require('./vulnerability-reporter')
2
4
  const { enableAllAnalyzers, disableAllAnalyzers } = require('./analyzers')
3
5
  const web = require('../../plugins/util/web')
@@ -1,6 +1,6 @@
1
1
  'use strict'
2
2
 
3
- const LRUCache = require('lru-cache')
3
+ const { LRUCache } = require('lru-cache')
4
4
  const web = require('../../plugins/util/web')
5
5
  const vulnerabilities = require('./vulnerabilities')
6
6
 
@@ -28,7 +28,10 @@ function taintObject (iastContext, object, type) {
28
28
  } else {
29
29
  result = tainted
30
30
  }
31
- } else if (typeof value === 'object' && !visited.has(value)) {
31
+ } else if (
32
+ // eslint-disable-next-line eslint-rules/eslint-safe-typeof-object
33
+ typeof value === 'object' && !visited.has(value)
34
+ ) {
32
35
  visited.add(value)
33
36
 
34
37
  for (const key of Object.keys(value)) {
@@ -69,7 +72,7 @@ function traverseAndTaint (node, path, cache, transactionId) {
69
72
  return tainted
70
73
  }
71
74
 
72
- if (typeof node === 'object') {
75
+ if (typeof node === 'object') { // eslint-disable-line eslint-rules/eslint-safe-typeof-object
73
76
  const keys = Array.isArray(node) ? node.keys() : Object.keys(node)
74
77
 
75
78
  for (const key of keys) {
@@ -1,5 +1,3 @@
1
- 'use strict'
2
-
3
1
  import path from 'path'
4
2
  import { URL } from 'url'
5
3
  import { getName } from '../telemetry/verbosity.js'
@@ -1,5 +1,7 @@
1
1
  'use strict'
2
2
 
3
+ /* eslint n/no-unsupported-features/node-builtins: ['error', { ignores: ['module.register'] }] */
4
+
3
5
  const Module = require('module')
4
6
  const { pathToFileURL } = require('url')
5
7
  const { MessageChannel } = require('worker_threads')
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  // eslint-disable-next-line @stylistic/max-len
2
4
  const DEFAULT_IAST_REDACTION_NAME_PATTERN = '(?:p(?:ass)?w(?:or)?d|pass(?:_?phrase)?|secret|(?:api_?|private_?|public_?|access_?|secret_?)key(?:_?id)?|token|consumer_?(?:id|key|secret)|sign(?:ed|ature)?|auth(?:entication|orization)?|(?:sur|last)name|user(?:name)?|address|e?mail)'
3
5
  // eslint-disable-next-line @stylistic/max-len
@@ -45,6 +45,7 @@ class VulnerabilityFormatter {
45
45
 
46
46
  if (evidence.value == null) return { valueParts }
47
47
 
48
+ // eslint-disable-next-line eslint-rules/eslint-safe-typeof-object
48
49
  if (typeof evidence.value === 'object' && evidence.rangesToApply) {
49
50
  const { value, ranges } = stringifyWithRanges(evidence.value, evidence.rangesToApply)
50
51
  evidence.value = value