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.
- package/LICENSE-3rdparty.csv +3 -1
- package/ci/cypress/after-run.js +2 -0
- package/ci/cypress/after-spec.js +2 -0
- package/ci/cypress/plugin.js +2 -0
- package/ci/cypress/polyfills.js +2 -0
- package/ci/cypress/support.js +2 -0
- package/ci/init.js +2 -0
- package/index.d.ts +7 -0
- package/init.js +1 -6
- package/initialize.mjs +2 -0
- package/package.json +40 -9
- package/packages/datadog-code-origin/index.js +14 -9
- package/packages/datadog-instrumentations/src/apollo.js +7 -10
- package/packages/datadog-instrumentations/src/avsc.js +2 -0
- package/packages/datadog-instrumentations/src/azure-functions.js +1 -1
- package/packages/datadog-instrumentations/src/child_process.js +22 -43
- package/packages/datadog-instrumentations/src/cucumber.js +10 -8
- package/packages/datadog-instrumentations/src/cypress.js +2 -0
- package/packages/datadog-instrumentations/src/fastify.js +19 -1
- package/packages/datadog-instrumentations/src/graphql.js +9 -0
- package/packages/datadog-instrumentations/src/helpers/hooks.js +1 -0
- package/packages/datadog-instrumentations/src/helpers/register.js +2 -2
- package/packages/datadog-instrumentations/src/hono.js +102 -0
- package/packages/datadog-instrumentations/src/jest.js +1 -1
- package/packages/datadog-instrumentations/src/langchain.js +21 -0
- package/packages/datadog-instrumentations/src/mocha/common.js +2 -0
- package/packages/datadog-instrumentations/src/mocha.js +2 -0
- package/packages/datadog-instrumentations/src/mysql2.js +6 -6
- package/packages/datadog-instrumentations/src/next.js +3 -1
- package/packages/datadog-instrumentations/src/nyc.js +2 -0
- package/packages/datadog-instrumentations/src/oracledb.js +24 -2
- package/packages/datadog-instrumentations/src/orchestrion-config/index.js +32 -0
- package/packages/datadog-instrumentations/src/playwright.js +5 -1
- package/packages/datadog-instrumentations/src/protobufjs.js +2 -0
- package/packages/datadog-instrumentations/src/selenium.js +2 -0
- package/packages/datadog-instrumentations/src/tedious.js +12 -17
- package/packages/datadog-instrumentations/src/vitest.js +2 -0
- package/packages/datadog-plugin-avsc/src/index.js +2 -0
- package/packages/datadog-plugin-avsc/src/schema_iterator.js +2 -0
- package/packages/datadog-plugin-aws-sdk/src/base.js +51 -1
- package/packages/datadog-plugin-aws-sdk/src/services/bedrockruntime/index.js +2 -0
- package/packages/datadog-plugin-child_process/src/index.js +30 -10
- package/packages/datadog-plugin-child_process/src/scrub-cmd-params.js +1 -1
- package/packages/datadog-plugin-cypress/src/after-run.js +2 -0
- package/packages/datadog-plugin-cypress/src/after-spec.js +2 -0
- package/packages/datadog-plugin-cypress/src/cypress-plugin.js +8 -3
- package/packages/datadog-plugin-cypress/src/index.js +2 -0
- package/packages/datadog-plugin-cypress/src/plugin.js +2 -0
- package/packages/datadog-plugin-cypress/src/support.js +21 -25
- package/packages/datadog-plugin-google-cloud-vertexai/src/utils.js +2 -0
- package/packages/datadog-plugin-graphql/src/tools/index.js +0 -2
- package/packages/datadog-plugin-graphql/src/tools/signature.js +0 -2
- package/packages/datadog-plugin-graphql/src/tools/transforms.js +0 -2
- package/packages/datadog-plugin-graphql/src/utils.js +2 -0
- package/packages/datadog-plugin-hono/src/index.js +28 -0
- package/packages/datadog-plugin-http/src/client.js +3 -4
- package/packages/datadog-plugin-http2/src/client.js +9 -8
- package/packages/datadog-plugin-jest/src/index.js +2 -0
- package/packages/datadog-plugin-jest/src/util.js +2 -0
- package/packages/datadog-plugin-kafkajs/src/batch-consumer.js +2 -0
- package/packages/datadog-plugin-langchain/src/handlers/chain.js +1 -1
- package/packages/datadog-plugin-langchain/src/handlers/language_models/chat_model.js +1 -1
- package/packages/datadog-plugin-langchain/src/handlers/language_models/llm.js +1 -1
- package/packages/datadog-plugin-langchain/src/tracing.js +36 -4
- package/packages/datadog-plugin-nyc/src/index.js +2 -0
- package/packages/datadog-plugin-oracledb/src/connection-parser.js +37 -0
- package/packages/datadog-plugin-oracledb/src/index.js +15 -17
- package/packages/datadog-plugin-protobufjs/src/index.js +2 -0
- package/packages/datadog-plugin-protobufjs/src/schema_iterator.js +2 -0
- package/packages/datadog-plugin-selenium/src/index.js +2 -0
- package/packages/datadog-plugin-tedious/src/index.js +10 -9
- package/packages/datadog-plugin-vitest/src/index.js +2 -0
- package/packages/dd-trace/src/appsec/iast/analyzers/injection-analyzer.js +6 -4
- package/packages/dd-trace/src/appsec/iast/analyzers/ssrf-analyzer.js +9 -0
- package/packages/dd-trace/src/appsec/iast/iast-context.js +5 -1
- package/packages/dd-trace/src/appsec/iast/index.js +2 -0
- package/packages/dd-trace/src/appsec/iast/overhead-controller.js +1 -1
- package/packages/dd-trace/src/appsec/iast/taint-tracking/operations-taint-object.js +5 -2
- package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter-esm.mjs +0 -2
- package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter.js +2 -0
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-regex.js +2 -0
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/index.js +1 -0
- package/packages/dd-trace/src/appsec/iast/vulnerabilities.js +2 -0
- package/packages/dd-trace/src/appsec/iast/vulnerability-reporter.js +3 -3
- package/packages/dd-trace/src/appsec/rasp/fs-plugin.js +18 -11
- package/packages/dd-trace/src/appsec/rasp/utils.js +1 -1
- package/packages/dd-trace/src/appsec/recommended.json +88 -2
- package/packages/dd-trace/src/appsec/reporter.js +68 -14
- package/packages/dd-trace/src/appsec/rule_manager.js +63 -171
- package/packages/dd-trace/src/appsec/sdk/track_event.js +3 -5
- package/packages/dd-trace/src/appsec/stack_trace.js +11 -11
- package/packages/dd-trace/src/appsec/telemetry/common.js +2 -2
- package/packages/dd-trace/src/appsec/telemetry/index.js +8 -0
- package/packages/dd-trace/src/appsec/telemetry/waf.js +5 -3
- package/packages/dd-trace/src/appsec/waf/diagnostics.js +15 -0
- package/packages/dd-trace/src/appsec/waf/index.js +47 -6
- package/packages/dd-trace/src/appsec/waf/waf_context_wrapper.js +2 -2
- package/packages/dd-trace/src/appsec/waf/waf_manager.js +22 -12
- package/packages/dd-trace/src/ci-visibility/dynamic-instrumentation/index.js +3 -3
- package/packages/dd-trace/src/ci-visibility/early-flake-detection/get-known-tests.js +2 -0
- package/packages/dd-trace/src/ci-visibility/exporters/git/git_metadata.js +3 -1
- package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +2 -0
- package/packages/dd-trace/src/ci-visibility/log-submission/log-submission-plugin.js +2 -0
- package/packages/dd-trace/src/ci-visibility/requests/get-library-configuration.js +2 -0
- package/packages/dd-trace/src/ci-visibility/telemetry.js +2 -0
- package/packages/dd-trace/src/ci-visibility/test-api-manual/test-api-manual-plugin.js +2 -0
- package/packages/dd-trace/src/ci-visibility/test-management/get-test-management-tests.js +7 -3
- package/packages/dd-trace/src/config.js +15 -4
- package/packages/dd-trace/src/config_stable.js +2 -0
- package/packages/dd-trace/src/constants.js +1 -2
- package/packages/dd-trace/src/datastreams/checkpointer.js +2 -0
- package/packages/dd-trace/src/datastreams/context.js +2 -0
- package/packages/dd-trace/src/datastreams/encoding.js +2 -0
- package/packages/dd-trace/src/datastreams/fnv.js +2 -0
- package/packages/dd-trace/src/datastreams/pathway.js +11 -9
- package/packages/dd-trace/src/datastreams/processor.js +8 -7
- package/packages/dd-trace/src/datastreams/schemas/schema.js +2 -0
- package/packages/dd-trace/src/datastreams/schemas/schema_builder.js +45 -36
- package/packages/dd-trace/src/datastreams/schemas/schema_sampler.js +2 -0
- package/packages/dd-trace/src/datastreams/writer.js +2 -0
- package/packages/dd-trace/src/debugger/devtools_client/index.js +12 -4
- package/packages/dd-trace/src/debugger/devtools_client/inspector_promises_polyfill.js +2 -0
- package/packages/dd-trace/src/debugger/devtools_client/remote_config.js +8 -5
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/symbols.js +1 -1
- package/packages/dd-trace/src/debugger/index.js +36 -9
- package/packages/dd-trace/src/encode/tags-processors.js +2 -0
- package/packages/dd-trace/src/exporters/common/agent-info-exporter.js +2 -0
- package/packages/dd-trace/src/exporters/common/request.js +1 -1
- package/packages/dd-trace/src/exporters/common/util.js +2 -0
- package/packages/dd-trace/src/exporters/span-stats/index.js +2 -0
- package/packages/dd-trace/src/exporters/span-stats/writer.js +2 -0
- package/packages/dd-trace/src/external-logger/src/index.js +2 -0
- package/packages/dd-trace/src/git_metadata_tagger.js +2 -0
- package/packages/dd-trace/src/git_properties.js +2 -0
- package/packages/dd-trace/src/guardrails/index.js +3 -4
- package/packages/dd-trace/src/guardrails/log.js +2 -2
- package/packages/dd-trace/src/guardrails/telemetry.js +16 -14
- package/packages/dd-trace/src/guardrails/util.js +0 -2
- package/packages/dd-trace/src/heap_snapshots.js +58 -0
- package/packages/dd-trace/src/llmobs/noop.js +1 -1
- package/packages/dd-trace/src/llmobs/plugins/bedrockruntime.js +2 -0
- package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/index.js +5 -0
- package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/tool.js +15 -0
- package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/vectorstore.js +36 -0
- package/packages/dd-trace/src/llmobs/plugins/langchain/index.js +47 -4
- package/packages/dd-trace/src/llmobs/span_processor.js +1 -1
- package/packages/dd-trace/src/llmobs/tagger.js +10 -1
- package/packages/dd-trace/src/log/log.js +1 -1
- package/packages/dd-trace/src/noop/dogstatsd.js +2 -0
- package/packages/dd-trace/src/opentracing/propagation/text_map_dsm.js +2 -0
- package/packages/dd-trace/src/opentracing/span.js +1 -1
- package/packages/dd-trace/src/payload-tagging/config/index.js +2 -0
- package/packages/dd-trace/src/payload-tagging/index.js +3 -1
- package/packages/dd-trace/src/payload-tagging/tagging.js +4 -2
- package/packages/dd-trace/src/plugins/apollo.js +2 -0
- package/packages/dd-trace/src/plugins/ci_plugin.js +8 -3
- package/packages/dd-trace/src/plugins/index.js +1 -0
- package/packages/dd-trace/src/plugins/outbound.js +7 -0
- package/packages/dd-trace/src/plugins/util/ci.js +2 -0
- package/packages/dd-trace/src/plugins/util/env.js +2 -0
- package/packages/dd-trace/src/plugins/util/git.js +40 -5
- package/packages/dd-trace/src/plugins/util/inferred_proxy.js +2 -0
- package/packages/dd-trace/src/plugins/util/llm.js +2 -0
- package/packages/dd-trace/src/plugins/util/serverless.js +2 -0
- package/packages/dd-trace/src/plugins/util/stacktrace.js +178 -50
- package/packages/dd-trace/src/plugins/util/tags.js +17 -1
- package/packages/dd-trace/src/plugins/util/test.js +9 -4
- package/packages/dd-trace/src/plugins/util/url.js +2 -0
- package/packages/dd-trace/src/plugins/util/user-provided-git.js +2 -0
- package/packages/dd-trace/src/profiling/exporters/event_serializer.js +4 -0
- package/packages/dd-trace/src/profiling/profiler.js +89 -70
- package/packages/dd-trace/src/profiling/profilers/event_plugins/dns.js +2 -0
- package/packages/dd-trace/src/profiling/profilers/event_plugins/dns_lookup.js +2 -0
- package/packages/dd-trace/src/profiling/profilers/event_plugins/dns_lookupservice.js +2 -0
- package/packages/dd-trace/src/profiling/profilers/event_plugins/dns_resolve.js +2 -0
- package/packages/dd-trace/src/profiling/profilers/event_plugins/dns_reverse.js +2 -0
- package/packages/dd-trace/src/profiling/profilers/event_plugins/event.js +2 -0
- package/packages/dd-trace/src/profiling/profilers/event_plugins/fs.js +2 -0
- package/packages/dd-trace/src/profiling/profilers/event_plugins/net.js +2 -0
- package/packages/dd-trace/src/profiling/profilers/events.js +2 -0
- package/packages/dd-trace/src/profiling/profilers/wall.js +2 -2
- package/packages/dd-trace/src/profiling/webspan-utils.js +2 -0
- package/packages/dd-trace/src/proxy.js +4 -0
- package/packages/dd-trace/src/remote_config/capabilities.js +3 -1
- package/packages/dd-trace/src/remote_config/index.js +4 -0
- package/packages/dd-trace/src/service-naming/index.js +2 -0
- package/packages/dd-trace/src/service-naming/schemas/definition.js +4 -9
- package/packages/dd-trace/src/service-naming/schemas/util.js +2 -0
- package/packages/dd-trace/src/service-naming/schemas/v0/graphql.js +2 -0
- package/packages/dd-trace/src/service-naming/schemas/v0/index.js +2 -0
- package/packages/dd-trace/src/service-naming/schemas/v0/messaging.js +2 -0
- package/packages/dd-trace/src/service-naming/schemas/v0/serverless.js +2 -0
- package/packages/dd-trace/src/service-naming/schemas/v0/storage.js +2 -0
- package/packages/dd-trace/src/service-naming/schemas/v0/web.js +2 -0
- package/packages/dd-trace/src/service-naming/schemas/v1/graphql.js +2 -0
- package/packages/dd-trace/src/service-naming/schemas/v1/index.js +2 -0
- package/packages/dd-trace/src/service-naming/schemas/v1/messaging.js +2 -0
- package/packages/dd-trace/src/service-naming/schemas/v1/serverless.js +2 -0
- package/packages/dd-trace/src/service-naming/schemas/v1/storage.js +4 -1
- package/packages/dd-trace/src/service-naming/schemas/v1/web.js +2 -0
- package/packages/dd-trace/src/span_stats.js +2 -0
- package/packages/dd-trace/src/supported-configurations.json +5 -0
- package/packages/dd-trace/src/telemetry/send-data.js +2 -0
- package/register.js +4 -0
- package/version.js +0 -3
- package/packages/dd-trace/src/payload-tagging/jsonpath-plus.js +0 -2094
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
|
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
|
-
//
|
|
34
|
-
|
|
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
|
-
|
|
68
|
-
|
|
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
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
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
|
|
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
|
|
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
|
|
163
|
+
} catch {
|
|
168
164
|
// ignore error and continue
|
|
169
165
|
}
|
|
170
166
|
cy.task('dd:afterEach', { test: testInfo, coverage })
|
|
@@ -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 (
|
|
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
|
-
|
|
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 (
|
|
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(
|
|
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
|
-
|
|
115
|
+
super.finish(ctx)
|
|
114
116
|
}
|
|
115
117
|
|
|
116
|
-
_onClose (
|
|
117
|
-
|
|
118
|
-
span.finish()
|
|
118
|
+
_onClose (ctx) {
|
|
119
|
+
super.finish(ctx)
|
|
119
120
|
}
|
|
120
121
|
}
|
|
121
122
|
|
|
@@ -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
|
|
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
|
]
|
|
@@ -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
|
-
|
|
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
|
-
|
|
15
|
-
|
|
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':
|
|
25
|
-
'db.hostname':
|
|
26
|
-
[CLIENT_PORT_KEY]:
|
|
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
|
|
@@ -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
|
-
|
|
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:
|
|
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':
|
|
22
|
-
[CLIENT_PORT_KEY]:
|
|
23
|
-
'db.user':
|
|
24
|
-
'db.name':
|
|
25
|
-
'db.instance':
|
|
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
|
-
|
|
31
|
+
ctx.sql = this.injectDbmQuery(span, ctx.queryOrProcedure, service, true)
|
|
32
|
+
return ctx.currentStore
|
|
32
33
|
}
|
|
33
34
|
}
|
|
34
35
|
|
|
@@ -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
|
-
|
|
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
|
|
@@ -28,7 +28,10 @@ function taintObject (iastContext, object, type) {
|
|
|
28
28
|
} else {
|
|
29
29
|
result = tainted
|
|
30
30
|
}
|
|
31
|
-
} else if (
|
|
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,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
|