dd-trace 5.135.0 → 5.137.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/README.md +3 -0
- package/ci/cypress/support.js +2 -1
- package/ci/init.js +2 -22
- package/ci/vitest-no-worker-init-node-setup.mjs +2 -1
- package/ci/vitest-no-worker-init-runner-setup.mjs +2 -1
- package/ci/vitest-no-worker-init-setup.mjs +729 -724
- package/ci/vitest-no-worker-init-v5-setup.mjs +2 -1
- package/ext/exporters.js +0 -1
- package/index.d.ts +105 -5
- package/initialize.mjs +5 -2
- package/package.json +41 -36
- package/packages/datadog-esbuild/index.js +16 -70
- package/packages/datadog-esbuild/src/log.js +2 -29
- package/packages/datadog-instrumentations/src/ai.js +6 -1
- package/packages/datadog-instrumentations/src/aws-lambda.js +88 -0
- package/packages/datadog-instrumentations/src/cucumber.js +5 -2
- package/packages/datadog-instrumentations/src/cypress-config.js +20 -9
- package/packages/datadog-instrumentations/src/elevenlabs/activity.js +114 -0
- package/packages/datadog-instrumentations/src/elevenlabs/audio.js +104 -0
- package/packages/datadog-instrumentations/src/elevenlabs/index.js +288 -0
- package/packages/datadog-instrumentations/src/elevenlabs/session.js +444 -0
- package/packages/datadog-instrumentations/src/graphql.js +20 -17
- package/packages/datadog-instrumentations/src/helpers/bundler-esm-exports.js +582 -0
- package/packages/datadog-instrumentations/src/helpers/bundler-log.js +38 -0
- package/packages/datadog-instrumentations/src/helpers/bundler-transform.js +576 -0
- package/packages/datadog-instrumentations/src/helpers/bundler-utils.js +104 -0
- package/packages/datadog-instrumentations/src/helpers/fetch.js +51 -6
- package/packages/datadog-instrumentations/src/helpers/hook.js +29 -1
- package/packages/datadog-instrumentations/src/helpers/hooks.js +3 -7
- package/packages/datadog-instrumentations/src/helpers/lambda-handler.js +189 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/index.js +8 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentation-registry.js +26 -1
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/async-mutex.js +41 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/elevenlabs.js +25 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/graphql.js +0 -36
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/modelcontextprotocol-client.js +30 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/modelcontextprotocol-server.js +23 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/next.js +61 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/openai-agents-realtime.js +23 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/postgres.js +33 -4
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/trpc.js +148 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/target-patterns.json +80 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/targets.json +23 -3
- package/packages/datadog-instrumentations/src/helpers/rewriter/transforms/postgres.js +122 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/transforms.js +59 -2
- package/packages/datadog-instrumentations/src/ioredis.js +101 -3
- package/packages/datadog-instrumentations/src/microgateway-core.js +1 -2
- package/packages/datadog-instrumentations/src/modelcontextprotocol-client.js +21 -0
- package/packages/datadog-instrumentations/src/modelcontextprotocol-sdk.js +7 -1
- package/packages/datadog-instrumentations/src/modelcontextprotocol-server.js +41 -0
- package/packages/datadog-instrumentations/src/next.js +203 -26
- package/packages/datadog-instrumentations/src/openai-agents-realtime.js +149 -0
- package/packages/datadog-instrumentations/src/openai-realtime/audio-accumulator.js +27 -0
- package/packages/datadog-instrumentations/src/openai-realtime/index.js +17 -6
- package/packages/datadog-instrumentations/src/openai-realtime/server-playback.js +887 -0
- package/packages/datadog-instrumentations/src/openai-realtime/session.js +150 -25
- package/packages/datadog-instrumentations/src/openai-realtime/turns.js +29 -2
- package/packages/datadog-instrumentations/src/otel-sdk-trace.js +11 -9
- package/packages/datadog-instrumentations/src/router.js +35 -12
- package/packages/datadog-instrumentations/src/vitest-main.js +10 -2
- package/packages/datadog-instrumentations/src/webdriverio.js +12 -12
- package/packages/datadog-plugin-async-mutex/src/index.js +50 -0
- package/packages/datadog-plugin-aws-lambda/src/arn.js +41 -0
- package/packages/datadog-plugin-aws-lambda/src/event-type-guards.js +170 -0
- package/packages/datadog-plugin-aws-lambda/src/index.js +106 -0
- package/packages/datadog-plugin-aws-lambda/src/trigger.js +339 -0
- package/packages/datadog-plugin-aws-sdk/src/services/dynamodb.js +7 -0
- package/packages/datadog-plugin-aws-sdk/src/services/kinesis.js +32 -10
- package/packages/datadog-plugin-aws-sdk/src/services/lambda.js +10 -1
- package/packages/datadog-plugin-aws-sdk/src/services/sqs.js +4 -0
- package/packages/datadog-plugin-aws-sdk/src/services/stepfunctions.js +3 -0
- package/packages/datadog-plugin-cypress/src/cypress-plugin.js +50 -13
- package/packages/datadog-plugin-cypress/src/support.mjs +1353 -0
- package/packages/datadog-plugin-elevenlabs/src/index.js +69 -0
- package/packages/datadog-plugin-express/src/code_origin.js +2 -2
- package/packages/datadog-plugin-fastify/src/code_origin.js +2 -2
- package/packages/datadog-plugin-google-cloud-pubsub/src/consumer.js +20 -7
- package/packages/datadog-plugin-google-cloud-pubsub/src/producer.js +21 -52
- package/packages/datadog-plugin-google-cloud-pubsub/src/pubsub-push-subscription.js +11 -2
- package/packages/datadog-plugin-google-cloud-pubsub/src/pubsub-request-context.js +25 -4
- package/packages/datadog-plugin-google-cloud-pubsub/src/resource-names.js +24 -0
- package/packages/datadog-plugin-graphql/src/tools/transforms.js +1 -0
- package/packages/datadog-plugin-http/src/client.js +34 -10
- package/packages/datadog-plugin-http2/src/client.js +40 -14
- package/packages/datadog-plugin-modelcontextprotocol-sdk/src/tracing.js +28 -2
- package/packages/datadog-plugin-modelcontextprotocol-sdk/src/utils.js +1 -0
- package/packages/datadog-plugin-mongodb-core/src/query.js +17 -1
- package/packages/datadog-plugin-next/src/index.js +112 -14
- package/packages/datadog-plugin-postgres/src/index.js +118 -41
- package/packages/datadog-plugin-prisma/src/datadog-tracing-helper.js +5 -3
- package/packages/datadog-plugin-supabase/src/supabase-auth-js-gotrueclient-getuser.js +18 -8
- package/packages/datadog-plugin-supabase/src/supabase-functions-js-functionsclient-invoke.js +49 -13
- package/packages/datadog-plugin-supabase/src/supabase-storage-js-handle-request.js +34 -9
- package/packages/datadog-plugin-trpc/src/index.js +15 -0
- package/packages/datadog-plugin-trpc/src/procedure.js +48 -0
- package/packages/datadog-plugin-trpc/src/request.js +81 -0
- package/packages/datadog-plugin-undici/src/index.js +22 -7
- package/packages/datadog-plugin-vitest/src/index.js +3 -2
- package/packages/datadog-plugin-ws/src/close.js +3 -5
- package/packages/datadog-plugin-ws/src/producer.js +1 -4
- package/packages/datadog-plugin-ws/src/receiver.js +3 -5
- package/packages/datadog-plugin-ws/src/server.js +44 -13
- package/packages/datadog-turbopack/index.js +4 -28
- package/packages/datadog-turbopack/src/loader.js +14 -452
- package/packages/datadog-vite/index.js +537 -0
- package/packages/datadog-vite/src/log.js +5 -0
- package/packages/datadog-webpack/index.js +3 -55
- package/packages/datadog-webpack/src/log.js +2 -29
- package/packages/dd-trace/src/aiguard/evaluation.js +62 -1
- package/packages/dd-trace/src/aiguard/index.js +1 -1
- package/packages/dd-trace/src/aiguard/integrations/index.js +6 -5
- package/packages/dd-trace/src/aiguard/sdk.js +8 -2
- package/packages/dd-trace/src/aiguard/tags.js +2 -0
- package/packages/dd-trace/src/appsec/blocking/index.js +21 -1
- package/packages/dd-trace/src/appsec/channels.js +7 -0
- package/packages/dd-trace/src/appsec/downstream_requests.js +105 -0
- package/packages/dd-trace/src/appsec/graphql.js +89 -7
- package/packages/dd-trace/src/appsec/handlers/auth.js +1 -3
- package/packages/dd-trace/src/appsec/handlers/http-request.js +60 -65
- package/packages/dd-trace/src/appsec/handlers/http-response.js +61 -7
- package/packages/dd-trace/src/appsec/handlers/payments.js +23 -27
- package/packages/dd-trace/src/appsec/index.js +6 -0
- package/packages/dd-trace/src/appsec/lambda.js +17 -17
- package/packages/dd-trace/src/appsec/rasp/command_injection.js +4 -4
- package/packages/dd-trace/src/appsec/rasp/index.js +8 -1
- package/packages/dd-trace/src/appsec/rasp/lfi.js +2 -2
- package/packages/dd-trace/src/appsec/rasp/sql_injection.js +7 -17
- package/packages/dd-trace/src/appsec/rasp/ssrf.js +80 -16
- package/packages/dd-trace/src/appsec/rasp/utils.js +33 -3
- package/packages/dd-trace/src/appsec/recommended.json +1358 -94
- package/packages/dd-trace/src/appsec/reporter.js +9 -0
- package/packages/dd-trace/src/appsec/sdk/set_user.js +3 -3
- package/packages/dd-trace/src/appsec/sdk/track_event.js +4 -4
- package/packages/dd-trace/src/appsec/sdk/user_blocking.js +1 -1
- package/packages/dd-trace/src/appsec/user_tracking.js +6 -8
- package/packages/dd-trace/src/appsec/waf/index.js +65 -6
- package/packages/dd-trace/src/appsec/waf/waf_context_wrapper.js +33 -38
- package/packages/dd-trace/src/appsec/waf/waf_manager.js +18 -2
- package/packages/dd-trace/src/before-exit.js +32 -0
- package/packages/dd-trace/src/bootstrap.js +5 -3
- package/packages/dd-trace/src/ci-visibility/early-flake-detection/get-known-tests.js +15 -2
- package/packages/dd-trace/src/ci-visibility/exporters/ci-visibility-exporter.js +12 -34
- package/packages/dd-trace/src/ci-visibility/exporters/git/git_metadata.js +41 -13
- package/packages/dd-trace/src/ci-visibility/exporters/request.js +2 -3
- package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +1 -2
- package/packages/dd-trace/src/ci-visibility/requests/get-library-configuration.js +1 -1
- package/packages/dd-trace/src/ci-visibility/telemetry.js +6 -0
- package/packages/dd-trace/src/ci-visibility/test-management/get-test-management-tests.js +1 -1
- package/packages/dd-trace/src/ci-visibility/test-optimization-http-cache-schema.js +9 -134
- package/packages/dd-trace/src/ci-visibility/test-optimization-http-cache.js +11 -156
- package/packages/dd-trace/src/config/config-types.d.ts +3 -0
- package/packages/dd-trace/src/config/defaults.js +5 -0
- package/packages/dd-trace/src/config/generated-config-types.d.ts +46 -4
- package/packages/dd-trace/src/config/index.js +63 -31
- package/packages/dd-trace/src/config/parsers.js +44 -0
- package/packages/dd-trace/src/config/remote-config-layers.js +38 -0
- package/packages/dd-trace/src/config/remote_config.js +2 -1
- package/packages/dd-trace/src/config/supported-configurations.json +172 -10
- package/packages/dd-trace/src/constants.js +1 -0
- package/packages/dd-trace/src/datastreams/fnv.js +27 -0
- package/packages/dd-trace/src/datastreams/pathway.js +113 -28
- package/packages/dd-trace/src/datastreams/processor.js +5 -4
- package/packages/dd-trace/src/debugger/config.js +1 -1
- package/packages/dd-trace/src/debugger/devtools_client/request-options.js +7 -9
- package/packages/dd-trace/src/debugger/devtools_client/send.js +1 -1
- package/packages/dd-trace/src/debugger/devtools_client/state.js +3 -1
- package/packages/dd-trace/src/debugger/devtools_client/tags.js +1 -1
- package/packages/dd-trace/src/debugger/index.js +2 -2
- package/packages/dd-trace/src/debugger/inspect-segment.js +3 -2
- package/packages/dd-trace/src/debugger/pause-duration-histogram.js +6 -2
- package/packages/dd-trace/src/debugger/probe_sampler.js +39 -17
- package/packages/dd-trace/src/debugger/unsupported-runtime.js +2 -0
- package/packages/dd-trace/src/exporter.js +0 -11
- package/packages/dd-trace/src/exporters/common/request.js +81 -48
- package/packages/dd-trace/src/exporters/common/retry.js +12 -7
- package/packages/dd-trace/src/exporters/common/url.js +1 -1
- package/packages/dd-trace/src/git_metadata.js +2 -1
- package/packages/dd-trace/src/id.js +1 -1
- package/packages/dd-trace/src/index.js +6 -3
- package/packages/dd-trace/src/lambda/facade.js +75 -0
- package/packages/dd-trace/src/lambda/handler.js +3 -41
- package/packages/dd-trace/src/lambda/index.js +38 -15
- package/packages/dd-trace/src/lambda/runtime/patch.js +19 -3
- package/packages/dd-trace/src/lambda/wrap.js +44 -0
- package/packages/dd-trace/src/llmobs/constants/tags.js +2 -0
- package/packages/dd-trace/src/llmobs/experiments/experiment.js +10 -5
- package/packages/dd-trace/src/llmobs/plugins/elevenlabs.js +96 -0
- package/packages/dd-trace/src/llmobs/plugins/genai/util.js +19 -6
- package/packages/dd-trace/src/llmobs/plugins/modelcontextprotocol-sdk/index.js +54 -3
- package/packages/dd-trace/src/llmobs/plugins/modelcontextprotocol-sdk/utils.js +81 -1
- package/packages/dd-trace/src/llmobs/plugins/openai/realtime.js +38 -11
- package/packages/dd-trace/src/llmobs/plugins/vertexai.js +10 -2
- package/packages/dd-trace/src/llmobs/sdk.js +19 -0
- package/packages/dd-trace/src/llmobs/span_processor.js +9 -0
- package/packages/dd-trace/src/llmobs/tagger.js +22 -0
- package/packages/dd-trace/src/log/channels.js +4 -0
- package/packages/dd-trace/src/log/writer.js +6 -1
- package/packages/dd-trace/src/openfeature/agentless_configuration_source.js +7 -0
- package/packages/dd-trace/src/openfeature/configuration_source.js +55 -27
- package/packages/dd-trace/src/openfeature/flag-selection.js +152 -0
- package/packages/dd-trace/src/openfeature/flagging_provider.js +19 -1
- package/packages/dd-trace/src/openfeature/writers/base.js +1 -3
- package/packages/dd-trace/src/opentelemetry/logs/index.js +11 -0
- package/packages/dd-trace/src/opentelemetry/logs/otlp_http_log_exporter.js +1 -1
- package/packages/dd-trace/src/opentelemetry/metrics/index.js +7 -1
- package/packages/dd-trace/src/opentelemetry/metrics/otlp_http_metric_exporter.js +1 -1
- package/packages/dd-trace/src/opentelemetry/metrics/otlp_span_stats_exporter.js +4 -1
- package/packages/dd-trace/src/opentelemetry/otlp/otlp_http_exporter_base.js +19 -1
- package/packages/dd-trace/src/opentelemetry/span-ending-hook.js +5 -1
- package/packages/dd-trace/src/opentelemetry/span-helpers.js +6 -1
- package/packages/dd-trace/src/opentelemetry/span.js +2 -2
- package/packages/dd-trace/src/opentelemetry/startup-config.js +174 -0
- package/packages/dd-trace/src/opentelemetry/trace/otlp_http_trace_exporter.js +1 -1
- package/packages/dd-trace/src/opentelemetry/trace/otlp_transformer.js +7 -1
- package/packages/dd-trace/src/opentracing/propagation/tracestate.js +77 -23
- package/packages/dd-trace/src/opentracing/tracer.js +24 -0
- package/packages/dd-trace/src/otel-thread-ctx.js +28 -31
- package/packages/dd-trace/src/plugin_manager.js +34 -7
- package/packages/dd-trace/src/plugins/ci_plugin.js +143 -17
- package/packages/dd-trace/src/plugins/index.js +8 -0
- package/packages/dd-trace/src/plugins/plugin.js +4 -2
- package/packages/dd-trace/src/plugins/tracing.js +1 -1
- package/packages/dd-trace/src/plugins/util/ci.js +52 -1
- package/packages/dd-trace/src/plugins/util/git-cache.js +4 -4
- package/packages/dd-trace/src/plugins/util/git.js +263 -82
- package/packages/dd-trace/src/plugins/util/http-otel-semantics.js +80 -56
- package/packages/dd-trace/src/plugins/util/inferred_proxy.js +12 -4
- package/packages/dd-trace/src/plugins/util/status-validator.js +23 -10
- package/packages/dd-trace/src/plugins/util/tags.js +6 -0
- package/packages/dd-trace/src/plugins/util/test.js +92 -40
- package/packages/dd-trace/src/plugins/util/url.js +18 -7
- package/packages/dd-trace/src/plugins/util/user-provided-git.js +6 -6
- package/packages/dd-trace/src/plugins/util/web.js +65 -10
- package/packages/dd-trace/src/process-tags/index.js +1 -1
- package/packages/dd-trace/src/profiler.js +74 -12
- package/packages/dd-trace/src/profiling/profiler.js +30 -2
- package/packages/dd-trace/src/profiling/profilers/space.js +3 -1
- package/packages/dd-trace/src/profiling/profilers/wall.js +4 -4
- package/packages/dd-trace/src/profiling/remote-config.js +354 -0
- package/packages/dd-trace/src/profiling/runtime-capabilities.js +11 -0
- package/packages/dd-trace/src/profiling/webspan-utils.js +6 -5
- package/packages/dd-trace/src/propagation-hash/index.js +7 -0
- package/packages/dd-trace/src/proxy.js +46 -54
- package/packages/dd-trace/src/span_processor.js +20 -0
- package/packages/dd-trace/src/startup-log.js +8 -6
- package/packages/dd-trace/src/telemetry/metrics.js +2 -1
- package/packages/dd-trace/src/tracer.js +0 -2
- package/packages/dd-trace/src/web-tags-cache.js +8 -9
- package/register.js +2 -1
- package/vendor/dist/@apm-js-collab/code-transformer/LICENSE +489 -0
- package/vendor/dist/@datadog/flagging-core/LICENSE +221 -0
- package/vendor/dist/@datadog/flagging-core/index.js +1 -0
- package/vendor/dist/@datadog/openfeature-node-server/LICENSE +21 -1
- package/vendor/dist/@datadog/openfeature-node-server/rules-based/LICENSE +3 -1
- package/vendor/dist/@datadog/sketches-js/LICENSE +263 -0
- package/vendor/dist/@datadog/source-map/LICENSE +1 -0
- package/vendor/dist/@isaacs/ttlcache/LICENSE +13 -0
- package/vendor/dist/@opentelemetry/core/LICENSE +220 -1
- package/vendor/dist/@opentelemetry/core/index.js +1 -1
- package/vendor/dist/crypto-randomuuid/LICENSE +3 -0
- package/vendor/dist/escape-string-regexp/LICENSE +13 -0
- package/vendor/dist/esquery/LICENSE +2 -0
- package/vendor/dist/https-proxy-agent/LICENSE +80 -1
- package/vendor/dist/istanbul-lib-coverage/LICENSE +2 -0
- package/vendor/dist/jest-docblock/LICENSE +16 -0
- package/vendor/dist/jsonpath-plus/LICENSE +13 -0
- package/vendor/dist/limiter/LICENSE +2 -0
- package/vendor/dist/lodash.sortby/LICENSE +2 -0
- package/vendor/dist/lru-cache/LICENSE +13 -0
- package/vendor/dist/meriyah/LICENSE +13 -0
- package/vendor/dist/module-details-from-path/LICENSE +2 -0
- package/vendor/dist/mutexify/promise/LICENSE +28 -0
- package/vendor/dist/pprof-format/LICENSE +13 -0
- package/vendor/dist/pprof-format/index.js +1 -1
- package/vendor/dist/protobufjs/LICENSE +219 -0
- package/vendor/dist/protobufjs/minimal/LICENSE +219 -0
- package/vendor/dist/proxy-from-env/LICENSE +13 -0
- package/vendor/dist/retry/LICENSE +2 -0
- package/vendor/dist/rfdc/LICENSE +2 -0
- package/vendor/dist/semifies/LICENSE +3 -1
- package/vendor/dist/shell-quote/LICENSE +3 -1
- package/vendor/dist/source-map/LICENSE +1 -0
- package/vendor/dist/source-map/lib/util/LICENSE +1 -0
- package/vendor/dist/tlhunter-sorted-set/LICENSE +2 -0
- package/vendor/dist/ttl-set/LICENSE +28 -0
- package/vite.d.ts +7 -0
- package/vite.js +3 -0
- package/ci/diagnose.js +0 -2215
- package/ci/runbook.md +0 -299
- package/ci/test-optimization-validation/approval-artifacts.js +0 -175
- package/ci/test-optimization-validation/approval.js +0 -386
- package/ci/test-optimization-validation/artifact-id.js +0 -18
- package/ci/test-optimization-validation/blocker-category.js +0 -24
- package/ci/test-optimization-validation/bounded-json.js +0 -120
- package/ci/test-optimization-validation/ci-command-candidate.js +0 -77
- package/ci/test-optimization-validation/ci-discovery.js +0 -192
- package/ci/test-optimization-validation/ci-package-scripts.js +0 -169
- package/ci/test-optimization-validation/ci-remediation.js +0 -283
- package/ci/test-optimization-validation/cli.js +0 -954
- package/ci/test-optimization-validation/command-blocker.js +0 -377
- package/ci/test-optimization-validation/command-output-policy.js +0 -188
- package/ci/test-optimization-validation/command-runner.js +0 -649
- package/ci/test-optimization-validation/environment.js +0 -88
- package/ci/test-optimization-validation/executable-approval.js +0 -47
- package/ci/test-optimization-validation/executable.js +0 -244
- package/ci/test-optimization-validation/execution-lock.js +0 -70
- package/ci/test-optimization-validation/framework-adapters/cucumber-validation.json +0 -3
- package/ci/test-optimization-validation/framework-adapters/cucumber.js +0 -767
- package/ci/test-optimization-validation/framework-adapters/cypress.js +0 -99
- package/ci/test-optimization-validation/framework-adapters/playwright.js +0 -175
- package/ci/test-optimization-validation/framework-adapters/vitest.js +0 -513
- package/ci/test-optimization-validation/generated-file-policy.js +0 -63
- package/ci/test-optimization-validation/generated-files.js +0 -425
- package/ci/test-optimization-validation/generated-test-contract.js +0 -284
- package/ci/test-optimization-validation/generated-verifier.js +0 -235
- package/ci/test-optimization-validation/literal-environment.js +0 -56
- package/ci/test-optimization-validation/literal-glob.js +0 -52
- package/ci/test-optimization-validation/manifest-loader.js +0 -116
- package/ci/test-optimization-validation/manifest-scaffold.js +0 -1276
- package/ci/test-optimization-validation/manifest-schema.js +0 -695
- package/ci/test-optimization-validation/offline-fixtures.js +0 -335
- package/ci/test-optimization-validation/offline-output.js +0 -406
- package/ci/test-optimization-validation/package-check.js +0 -97
- package/ci/test-optimization-validation/payload-normalizer.js +0 -72
- package/ci/test-optimization-validation/plan-writer.js +0 -541
- package/ci/test-optimization-validation/preflight-runner.js +0 -186
- package/ci/test-optimization-validation/project-build-artifact.js +0 -31
- package/ci/test-optimization-validation/redaction.js +0 -319
- package/ci/test-optimization-validation/report-writer.js +0 -666
- package/ci/test-optimization-validation/result-semantics.js +0 -103
- package/ci/test-optimization-validation/runner-command.js +0 -264
- package/ci/test-optimization-validation/runner-contract.js +0 -695
- package/ci/test-optimization-validation/safe-files.js +0 -202
- package/ci/test-optimization-validation/scenarios/auto-test-retries.js +0 -171
- package/ci/test-optimization-validation/scenarios/basic-reporting.js +0 -407
- package/ci/test-optimization-validation/scenarios/ci-wiring.js +0 -666
- package/ci/test-optimization-validation/scenarios/early-flake-detection.js +0 -142
- package/ci/test-optimization-validation/scenarios/helpers.js +0 -621
- package/ci/test-optimization-validation/scenarios/test-management.js +0 -219
- package/ci/test-optimization-validation/source-text.js +0 -84
- package/ci/test-optimization-validation/static-diagnosis.js +0 -166
- package/ci/test-optimization-validation/test-output.js +0 -120
- package/ci/test-optimization-validation/validation-blocker.js +0 -21
- package/ci/validate-test-optimization.js +0 -3
- package/packages/datadog-esbuild/src/resolver.js +0 -284
- package/packages/datadog-esbuild/src/utils.js +0 -318
- package/packages/datadog-plugin-cypress/src/support.js +0 -1348
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/index.js +0 -156
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/msgpack-to-json.js +0 -287
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/payload-projection.js +0 -84
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/sink.js +0 -368
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/writer.js +0 -59
|
@@ -32,6 +32,7 @@ function onRequestBodyParsed ({ req, res, body, abortController }) {
|
|
|
32
32
|
|
|
33
33
|
if (!req) {
|
|
34
34
|
req = getActiveRequest()
|
|
35
|
+
res ??= web.getContext(req)?.res
|
|
35
36
|
}
|
|
36
37
|
|
|
37
38
|
const rootSpan = web.root(req)
|
|
@@ -48,9 +49,7 @@ function onRequestBodyParsed ({ req, res, body, abortController }) {
|
|
|
48
49
|
}
|
|
49
50
|
|
|
50
51
|
const results = waf.run({
|
|
51
|
-
|
|
52
|
-
[addresses.HTTP_INCOMING_BODY]: body,
|
|
53
|
-
},
|
|
52
|
+
[addresses.HTTP_INCOMING_BODY]: body,
|
|
54
53
|
}, req)
|
|
55
54
|
|
|
56
55
|
handleResults(results?.actions, req, res, rootSpan, abortController)
|
|
@@ -64,9 +63,7 @@ function onRequestCookieParser ({ req, res, abortController, cookies }) {
|
|
|
64
63
|
analyzedCookies.add(cookies)
|
|
65
64
|
|
|
66
65
|
const results = waf.run({
|
|
67
|
-
|
|
68
|
-
[addresses.HTTP_INCOMING_COOKIES]: cookies,
|
|
69
|
-
},
|
|
66
|
+
[addresses.HTTP_INCOMING_COOKIES]: cookies,
|
|
70
67
|
}, req)
|
|
71
68
|
|
|
72
69
|
handleResults(results?.actions, req, res, rootSpan, abortController)
|
|
@@ -91,82 +88,84 @@ function incomingHttpStartTranslator ({ req, res, abortController }) {
|
|
|
91
88
|
}
|
|
92
89
|
}
|
|
93
90
|
|
|
94
|
-
const
|
|
91
|
+
const requestData = {
|
|
95
92
|
[addresses.HTTP_INCOMING_URL]: req.url,
|
|
96
93
|
[addresses.HTTP_INCOMING_HEADERS]: copyHeadersOmitting(req.headers, 'cookie'),
|
|
97
94
|
[addresses.HTTP_INCOMING_METHOD]: req.method,
|
|
98
95
|
}
|
|
99
96
|
|
|
100
97
|
if (clientIp) {
|
|
101
|
-
|
|
98
|
+
requestData[addresses.HTTP_CLIENT_IP] = clientIp
|
|
102
99
|
}
|
|
103
100
|
|
|
104
|
-
const results = waf.run(
|
|
101
|
+
const results = waf.run(requestData, req)
|
|
105
102
|
|
|
106
103
|
handleResults(results?.actions, req, res, rootSpan, abortController)
|
|
107
104
|
}
|
|
108
105
|
|
|
109
106
|
function incomingHttpEndTranslator ({ req, res }) {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
if (
|
|
115
|
-
if (
|
|
116
|
-
|
|
107
|
+
try {
|
|
108
|
+
const requestData = {}
|
|
109
|
+
|
|
110
|
+
// we need to keep this to support other body parsers
|
|
111
|
+
if (req.body !== undefined && req.body !== null) {
|
|
112
|
+
if (typeof req.body === 'object') {
|
|
113
|
+
if (!isEmpty(req.body) && !analyzedBodies.has(req.body)) {
|
|
114
|
+
requestData[addresses.HTTP_INCOMING_BODY] = req.body
|
|
115
|
+
}
|
|
116
|
+
} else {
|
|
117
|
+
requestData[addresses.HTTP_INCOMING_BODY] = req.body
|
|
117
118
|
}
|
|
118
|
-
} else {
|
|
119
|
-
persistent[addresses.HTTP_INCOMING_BODY] = req.body
|
|
120
119
|
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
// we need to keep this to support other cookie parsers
|
|
124
|
-
if (
|
|
125
|
-
req.cookies !== null &&
|
|
126
|
-
typeof req.cookies === 'object' &&
|
|
127
|
-
!isEmpty(req.cookies) &&
|
|
128
|
-
!analyzedCookies.has(req.cookies)
|
|
129
|
-
) {
|
|
130
|
-
persistent[addresses.HTTP_INCOMING_COOKIES] = req.cookies
|
|
131
|
-
}
|
|
132
120
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
121
|
+
// we need to keep this to support other cookie parsers
|
|
122
|
+
if (
|
|
123
|
+
req.cookies !== null &&
|
|
124
|
+
typeof req.cookies === 'object' &&
|
|
125
|
+
!isEmpty(req.cookies) &&
|
|
126
|
+
!analyzedCookies.has(req.cookies)
|
|
127
|
+
) {
|
|
128
|
+
requestData[addresses.HTTP_INCOMING_COOKIES] = req.cookies
|
|
129
|
+
}
|
|
142
130
|
|
|
143
|
-
|
|
144
|
-
|
|
131
|
+
// we need to keep this to support nextjs
|
|
132
|
+
const query = req.query
|
|
133
|
+
if (
|
|
134
|
+
query !== null &&
|
|
135
|
+
typeof query === 'object' &&
|
|
136
|
+
!isEmpty(query)
|
|
137
|
+
) {
|
|
138
|
+
requestData[addresses.HTTP_INCOMING_QUERY] = query
|
|
139
|
+
}
|
|
145
140
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
141
|
+
// This hook runs before span finish, so ensure route/endpoint tags are available before API Security sampling runs.
|
|
142
|
+
web.setRouteOrEndpointTag(req)
|
|
143
|
+
|
|
144
|
+
if (config.appsec.DD_API_SECURITY_ENABLED) {
|
|
145
|
+
try {
|
|
146
|
+
const normalized = normalizeRoute(req)
|
|
147
|
+
if (normalized !== null) {
|
|
148
|
+
web.root(req)?.setTag('_dd.appsec.normalized_route', normalized)
|
|
149
|
+
}
|
|
150
|
+
} catch (e) {
|
|
151
|
+
log.debug('[ASM] Unable to compute normalized route: %s', e.message)
|
|
151
152
|
}
|
|
152
|
-
} catch (e) {
|
|
153
|
-
log.debug('[ASM] Unable to compute normalized route: %s', e.message)
|
|
154
153
|
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
const apiSecSamplingDecision = apiSecurity.sampleRequest(req, res, true)
|
|
158
|
-
if (apiSecSamplingDecision === apiSecurity.SamplingDecision.SAMPLE) {
|
|
159
|
-
persistent[addresses.WAF_CONTEXT_PROCESSOR] = { 'extract-schema': true }
|
|
160
|
-
}
|
|
161
154
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
155
|
+
const apiSecSamplingDecision = apiSecurity.sampleRequest(req, res, true)
|
|
156
|
+
if (apiSecSamplingDecision === apiSecurity.SamplingDecision.SAMPLE) {
|
|
157
|
+
requestData[addresses.WAF_CONTEXT_PROCESSOR] = { 'extract-schema': true }
|
|
158
|
+
}
|
|
166
159
|
|
|
167
|
-
|
|
160
|
+
let wafResult
|
|
161
|
+
if (!isEmpty(requestData)) {
|
|
162
|
+
wafResult = waf.run(requestData, req)
|
|
163
|
+
}
|
|
168
164
|
|
|
169
|
-
|
|
165
|
+
apiSecurity.reportRequest(req, apiSecSamplingDecision, wafResult)
|
|
166
|
+
} finally {
|
|
167
|
+
waf.disposeContext(req)
|
|
168
|
+
}
|
|
170
169
|
|
|
171
170
|
const storedHeaders = storedResponseHeaders.get(req) || {}
|
|
172
171
|
|
|
@@ -190,9 +189,7 @@ function onRequestQueryParsed ({ req, res, query, abortController }) {
|
|
|
190
189
|
if (!rootSpan || isEmpty(query)) return
|
|
191
190
|
|
|
192
191
|
const results = waf.run({
|
|
193
|
-
|
|
194
|
-
[addresses.HTTP_INCOMING_QUERY]: query,
|
|
195
|
-
},
|
|
192
|
+
[addresses.HTTP_INCOMING_QUERY]: query,
|
|
196
193
|
}, req)
|
|
197
194
|
|
|
198
195
|
handleResults(results?.actions, req, res, rootSpan, abortController)
|
|
@@ -203,9 +200,7 @@ function onRequestProcessParams ({ req, res, abortController, params }) {
|
|
|
203
200
|
if (!rootSpan || !params || typeof params !== 'object' || isEmpty(params)) return
|
|
204
201
|
|
|
205
202
|
const results = waf.run({
|
|
206
|
-
|
|
207
|
-
[addresses.HTTP_INCOMING_PARAMS]: params,
|
|
208
|
-
},
|
|
203
|
+
[addresses.HTTP_INCOMING_PARAMS]: params,
|
|
209
204
|
}, req)
|
|
210
205
|
|
|
211
206
|
handleResults(results?.actions, req, res, rootSpan, abortController)
|
|
@@ -1,14 +1,69 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
+
const { Stream } = require('node:stream')
|
|
4
|
+
|
|
3
5
|
const web = require('../../plugins/util/web')
|
|
4
6
|
const { isEmpty } = require('../../util')
|
|
5
7
|
const addresses = require('../addresses')
|
|
6
8
|
const apiSecurity = require('../api_security')
|
|
7
9
|
const { isBlocked, callBlockDelegation, handleResults } = require('../blocking')
|
|
10
|
+
const { getActiveRequest } = require('../store')
|
|
8
11
|
const waf = require('../waf')
|
|
9
12
|
const { storedResponseHeaders, copyHeadersOmitting } = require('./http-shared')
|
|
10
13
|
|
|
11
14
|
const responseAnalyzedSet = new WeakSet()
|
|
15
|
+
const nextResponseBodies = new WeakMap()
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @param {unknown} body
|
|
19
|
+
* @returns {body is object}
|
|
20
|
+
*/
|
|
21
|
+
function isJsonBody (body) {
|
|
22
|
+
return body !== null && typeof body === 'object' && !Buffer.isBuffer(body) && !(body instanceof Stream)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @param {{ stream: ReadableStream | null, body: unknown }} ctx
|
|
27
|
+
*/
|
|
28
|
+
function onNextJsonResponse ({ stream, body }) {
|
|
29
|
+
// NextResponse wraps the native Response but retains its body stream.
|
|
30
|
+
if (stream && isJsonBody(body)) nextResponseBodies.set(stream, body)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Pages Router `res.json()` and `res.send()`.
|
|
35
|
+
*
|
|
36
|
+
* @param {{ arguments: unknown[] }} ctx
|
|
37
|
+
*/
|
|
38
|
+
function onNextResponseBody (ctx) {
|
|
39
|
+
const body = ctx.arguments[0]
|
|
40
|
+
if (!isJsonBody(body)) return
|
|
41
|
+
|
|
42
|
+
const req = /** @type {import('node:http').IncomingMessage | undefined} */ (getActiveRequest())
|
|
43
|
+
if (!req || req.method === 'HEAD') return
|
|
44
|
+
|
|
45
|
+
const res = web.getContext(req)?.res
|
|
46
|
+
if (res) onResponseBody({ req, res, body })
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* App Router route handler result. Only the returned response is analyzed.
|
|
51
|
+
*
|
|
52
|
+
* @param {{ result?: Response, error?: unknown }} ctx
|
|
53
|
+
*/
|
|
54
|
+
function onNextAppRouteResponse (ctx) {
|
|
55
|
+
// Async completion is also published for rejected route handlers, including rejection with undefined.
|
|
56
|
+
if ('error' in ctx) return
|
|
57
|
+
|
|
58
|
+
const response = ctx.result
|
|
59
|
+
const body = response?.body && nextResponseBodies.get(response.body)
|
|
60
|
+
if (!body) return
|
|
61
|
+
|
|
62
|
+
const req = /** @type {import('node:http').IncomingMessage | undefined} */ (getActiveRequest())
|
|
63
|
+
if (!req || req.method === 'HEAD') return
|
|
64
|
+
|
|
65
|
+
onResponseBody({ req, res: { statusCode: response.status }, body })
|
|
66
|
+
}
|
|
12
67
|
|
|
13
68
|
function onResponseBody ({ req, res, body }) {
|
|
14
69
|
if (
|
|
@@ -21,9 +76,7 @@ function onResponseBody ({ req, res, body }) {
|
|
|
21
76
|
|
|
22
77
|
// we don't support blocking at this point, so no results needed
|
|
23
78
|
waf.run({
|
|
24
|
-
|
|
25
|
-
[addresses.HTTP_INCOMING_RESPONSE_BODY]: body,
|
|
26
|
-
},
|
|
79
|
+
[addresses.HTTP_INCOMING_RESPONSE_BODY]: body,
|
|
27
80
|
}, req)
|
|
28
81
|
}
|
|
29
82
|
|
|
@@ -59,10 +112,8 @@ function onResponseWriteHead ({ req, res, abortController, statusCode, responseH
|
|
|
59
112
|
if (!rootSpan) return
|
|
60
113
|
|
|
61
114
|
const results = waf.run({
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
[addresses.HTTP_INCOMING_RESPONSE_HEADERS]: copyHeadersOmitting(normalizedResponseHeaders, 'set-cookie'),
|
|
65
|
-
},
|
|
115
|
+
[addresses.HTTP_INCOMING_RESPONSE_CODE]: String(statusCode),
|
|
116
|
+
[addresses.HTTP_INCOMING_RESPONSE_HEADERS]: copyHeadersOmitting(normalizedResponseHeaders, 'set-cookie'),
|
|
66
117
|
}, req)
|
|
67
118
|
|
|
68
119
|
responseAnalyzedSet.add(res)
|
|
@@ -77,6 +128,9 @@ function onResponseOperation ({ res, abortController }) {
|
|
|
77
128
|
}
|
|
78
129
|
|
|
79
130
|
module.exports = {
|
|
131
|
+
onNextAppRouteResponse,
|
|
132
|
+
onNextResponseBody,
|
|
133
|
+
onNextJsonResponse,
|
|
80
134
|
onResponseBody,
|
|
81
135
|
onResponseWriteHead,
|
|
82
136
|
onResponseOperation,
|
|
@@ -7,19 +7,17 @@ function onStripeCheckoutSessionCreate (payload) {
|
|
|
7
7
|
if (payload?.mode !== 'payment') return
|
|
8
8
|
|
|
9
9
|
waf.run({
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
'total_details.amount_shipping': payload.total_details?.amount_shipping,
|
|
22
|
-
},
|
|
10
|
+
[addresses.PAYMENT_CREATION]: {
|
|
11
|
+
integration: 'stripe',
|
|
12
|
+
id: payload.id,
|
|
13
|
+
amount_total: payload.amount_total,
|
|
14
|
+
client_reference_id: payload.client_reference_id,
|
|
15
|
+
currency: payload.currency,
|
|
16
|
+
'discounts.coupon': payload.discounts?.[0]?.coupon,
|
|
17
|
+
'discounts.promotion_code': payload.discounts?.[0]?.promotion_code,
|
|
18
|
+
livemode: payload.livemode,
|
|
19
|
+
'total_details.amount_discount': payload.total_details?.amount_discount,
|
|
20
|
+
'total_details.amount_shipping': payload.total_details?.amount_shipping,
|
|
23
21
|
},
|
|
24
22
|
})
|
|
25
23
|
}
|
|
@@ -28,15 +26,13 @@ function onStripePaymentIntentCreate (payload) {
|
|
|
28
26
|
if (payload === null || typeof payload !== 'object') return
|
|
29
27
|
|
|
30
28
|
waf.run({
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
payment_method: payload.payment_method,
|
|
39
|
-
},
|
|
29
|
+
[addresses.PAYMENT_CREATION]: {
|
|
30
|
+
integration: 'stripe',
|
|
31
|
+
id: payload.id,
|
|
32
|
+
amount: payload.amount,
|
|
33
|
+
currency: payload.currency,
|
|
34
|
+
livemode: payload.livemode,
|
|
35
|
+
payment_method: payload.payment_method,
|
|
40
36
|
},
|
|
41
37
|
})
|
|
42
38
|
}
|
|
@@ -45,11 +41,11 @@ function onStripeConstructEvent (payload) {
|
|
|
45
41
|
const object = payload?.data?.object
|
|
46
42
|
if (object === null || typeof object !== 'object') return
|
|
47
43
|
|
|
48
|
-
let
|
|
44
|
+
let requestData
|
|
49
45
|
|
|
50
46
|
switch (payload.type) {
|
|
51
47
|
case 'payment_intent.succeeded':
|
|
52
|
-
|
|
48
|
+
requestData = {
|
|
53
49
|
[addresses.PAYMENT_SUCCESS]: {
|
|
54
50
|
integration: 'stripe',
|
|
55
51
|
id: object.id,
|
|
@@ -62,7 +58,7 @@ function onStripeConstructEvent (payload) {
|
|
|
62
58
|
break
|
|
63
59
|
|
|
64
60
|
case 'payment_intent.payment_failed':
|
|
65
|
-
|
|
61
|
+
requestData = {
|
|
66
62
|
[addresses.PAYMENT_FAILURE]: {
|
|
67
63
|
integration: 'stripe',
|
|
68
64
|
id: object.id,
|
|
@@ -78,7 +74,7 @@ function onStripeConstructEvent (payload) {
|
|
|
78
74
|
break
|
|
79
75
|
|
|
80
76
|
case 'payment_intent.canceled':
|
|
81
|
-
|
|
77
|
+
requestData = {
|
|
82
78
|
[addresses.PAYMENT_CANCELLATION]: {
|
|
83
79
|
integration: 'stripe',
|
|
84
80
|
id: object.id,
|
|
@@ -94,7 +90,7 @@ function onStripeConstructEvent (payload) {
|
|
|
94
90
|
return
|
|
95
91
|
}
|
|
96
92
|
|
|
97
|
-
waf.run(
|
|
93
|
+
waf.run(requestData)
|
|
98
94
|
}
|
|
99
95
|
|
|
100
96
|
module.exports = {
|
|
@@ -20,6 +20,9 @@ const {
|
|
|
20
20
|
queryParser,
|
|
21
21
|
nextBodyParsed,
|
|
22
22
|
nextQueryParsed,
|
|
23
|
+
nextResponseBody,
|
|
24
|
+
nextJsonResponse,
|
|
25
|
+
nextAppRouteResponse,
|
|
23
26
|
expressProcessParams,
|
|
24
27
|
fastifyQueryParams,
|
|
25
28
|
responseBody,
|
|
@@ -62,6 +65,9 @@ const channelHandlers = [
|
|
|
62
65
|
[queryParser, httpRequest.onRequestQueryParsed],
|
|
63
66
|
[nextBodyParsed, httpRequest.onRequestBodyParsed],
|
|
64
67
|
[nextQueryParsed, httpRequest.onRequestQueryParsed],
|
|
68
|
+
[nextResponseBody, httpResponse.onNextResponseBody],
|
|
69
|
+
[nextJsonResponse, httpResponse.onNextJsonResponse],
|
|
70
|
+
[nextAppRouteResponse, httpResponse.onNextAppRouteResponse],
|
|
65
71
|
[expressProcessParams, httpRequest.onRequestProcessParams],
|
|
66
72
|
[fastifyBodyParser, httpRequest.onRequestBodyParsed],
|
|
67
73
|
[fastifyQueryParams, httpRequest.onRequestQueryParsed],
|
|
@@ -41,43 +41,43 @@ function onLambdaStartInvocation (data) {
|
|
|
41
41
|
'_dd.runtime_family': 'nodejs',
|
|
42
42
|
})
|
|
43
43
|
|
|
44
|
-
const
|
|
44
|
+
const requestData = {}
|
|
45
45
|
|
|
46
46
|
if (path) {
|
|
47
|
-
|
|
47
|
+
requestData[addresses.HTTP_INCOMING_URL] = path
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
if (method) {
|
|
51
|
-
|
|
51
|
+
requestData[addresses.HTTP_INCOMING_METHOD] = method
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
if (headers) {
|
|
55
55
|
// Cookie header is already stripped by the Lambda layer's event-data-extractor
|
|
56
|
-
|
|
56
|
+
requestData[addresses.HTTP_INCOMING_HEADERS] = headers
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
if (clientIp) {
|
|
60
60
|
span.setTag(HTTP_CLIENT_IP, clientIp)
|
|
61
|
-
|
|
61
|
+
requestData[addresses.HTTP_CLIENT_IP] = clientIp
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
if (query) {
|
|
65
|
-
|
|
65
|
+
requestData[addresses.HTTP_INCOMING_QUERY] = query
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
if (body !== undefined && body !== null) {
|
|
69
|
-
|
|
69
|
+
requestData[addresses.HTTP_INCOMING_BODY] = body
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
if (pathParams) {
|
|
73
|
-
|
|
73
|
+
requestData[addresses.HTTP_INCOMING_PARAMS] = pathParams
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
if (cookies) {
|
|
77
|
-
|
|
77
|
+
requestData[addresses.HTTP_INCOMING_COOKIES] = cookies
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
waf.run(
|
|
80
|
+
waf.run(requestData, req, undefined, span)
|
|
81
81
|
} catch (err) {
|
|
82
82
|
log.error('[ASM] Error in Lambda start-invocation handler', err)
|
|
83
83
|
}
|
|
@@ -108,16 +108,16 @@ function onLambdaEndInvocation (data) {
|
|
|
108
108
|
activeInvocations.delete(span)
|
|
109
109
|
|
|
110
110
|
try {
|
|
111
|
-
const
|
|
111
|
+
const requestData = {}
|
|
112
112
|
|
|
113
113
|
if (statusCode) {
|
|
114
|
-
|
|
114
|
+
requestData[addresses.HTTP_INCOMING_RESPONSE_CODE] = String(statusCode)
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
if (responseHeaders) {
|
|
118
118
|
const filteredHeaders = { ...responseHeaders }
|
|
119
119
|
delete filteredHeaders['set-cookie']
|
|
120
|
-
|
|
120
|
+
requestData[addresses.HTTP_INCOMING_RESPONSE_HEADERS] = filteredHeaders
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
const samplingDecision = apiSecurity.sampleRootSpanRequest(span, {
|
|
@@ -129,17 +129,17 @@ function onLambdaEndInvocation (data) {
|
|
|
129
129
|
}, true)
|
|
130
130
|
|
|
131
131
|
if (samplingDecision === apiSecurity.SamplingDecision.SAMPLE) {
|
|
132
|
-
|
|
132
|
+
requestData[addresses.WAF_CONTEXT_PROCESSOR] = { 'extract-schema': true }
|
|
133
133
|
|
|
134
134
|
const parsedBody = parseResponseBody(responseBody, responseHeaders, isBase64Encoded)
|
|
135
135
|
if (parsedBody !== undefined) {
|
|
136
|
-
|
|
136
|
+
requestData[addresses.HTTP_INCOMING_RESPONSE_BODY] = parsedBody
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
139
|
|
|
140
140
|
let wafResult
|
|
141
|
-
if (!isEmpty(
|
|
142
|
-
wafResult = waf.run(
|
|
141
|
+
if (!isEmpty(requestData)) {
|
|
142
|
+
wafResult = waf.run(requestData, req, undefined, span)
|
|
143
143
|
}
|
|
144
144
|
|
|
145
145
|
apiSecurity.reportRootSpanRequest(span, samplingDecision, wafResult)
|
|
@@ -31,20 +31,20 @@ function analyzeCommandInjection ({ file, fileArgs, shell, abortController }) {
|
|
|
31
31
|
const req = getActiveRequest()
|
|
32
32
|
if (!req) return
|
|
33
33
|
|
|
34
|
-
const
|
|
34
|
+
const subcontextData = {}
|
|
35
35
|
const raspRule = { type: RULE_TYPES.COMMAND_INJECTION }
|
|
36
36
|
const params = fileArgs ? [file, ...fileArgs] : file
|
|
37
37
|
|
|
38
38
|
if (shell) {
|
|
39
|
-
|
|
39
|
+
subcontextData[addresses.SHELL_COMMAND] = params
|
|
40
40
|
raspRule.variant = 'shell'
|
|
41
41
|
} else {
|
|
42
42
|
const commandParams = Array.isArray(params) ? params : [params]
|
|
43
|
-
|
|
43
|
+
subcontextData[addresses.EXEC_COMMAND] = commandParams
|
|
44
44
|
raspRule.variant = 'exec'
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
const result = waf.
|
|
47
|
+
const result = waf.runSubContext(subcontextData, raspRule)
|
|
48
48
|
|
|
49
49
|
handleResult(result, req, web.getContext(req)?.res, abortController, config, raspRule)
|
|
50
50
|
}
|
|
@@ -6,6 +6,7 @@ const {
|
|
|
6
6
|
expressMiddlewareError,
|
|
7
7
|
fastifyMiddlewareError,
|
|
8
8
|
routerMiddlewareError,
|
|
9
|
+
nextRequestStart,
|
|
9
10
|
} = require('../channels')
|
|
10
11
|
const { block, registerBlockDelegation, isBlocked } = require('../blocking')
|
|
11
12
|
const { updateRaspRuleMatchMetricTags } = require('../telemetry')
|
|
@@ -14,7 +15,7 @@ const sqli = require('./sql_injection')
|
|
|
14
15
|
const lfi = require('./lfi')
|
|
15
16
|
const cmdi = require('./command_injection')
|
|
16
17
|
|
|
17
|
-
const { DatadogRaspAbortError } = require('./utils')
|
|
18
|
+
const { DatadogRaspAbortError, markToBlockOnDetection } = require('./utils')
|
|
18
19
|
|
|
19
20
|
function removeAllListeners (emitter, event) {
|
|
20
21
|
const listeners = emitter.listeners(event)
|
|
@@ -106,6 +107,10 @@ function blockOnDatadogRaspAbortError ({ error, isTopLevel }) {
|
|
|
106
107
|
return true
|
|
107
108
|
}
|
|
108
109
|
|
|
110
|
+
function onNextRequestStart ({ req, ignoreError }) {
|
|
111
|
+
markToBlockOnDetection(req, ignoreError)
|
|
112
|
+
}
|
|
113
|
+
|
|
109
114
|
function enable (config) {
|
|
110
115
|
ssrf.enable(config)
|
|
111
116
|
sqli.enable(config)
|
|
@@ -117,6 +122,7 @@ function enable (config) {
|
|
|
117
122
|
expressMiddlewareError.subscribe(blockOnDatadogRaspAbortError)
|
|
118
123
|
fastifyMiddlewareError.subscribe(blockOnDatadogRaspAbortError)
|
|
119
124
|
routerMiddlewareError.subscribe(blockOnDatadogRaspAbortError)
|
|
125
|
+
nextRequestStart.subscribe(onNextRequestStart)
|
|
120
126
|
}
|
|
121
127
|
|
|
122
128
|
function disable () {
|
|
@@ -130,6 +136,7 @@ function disable () {
|
|
|
130
136
|
expressMiddlewareError.unsubscribe(blockOnDatadogRaspAbortError)
|
|
131
137
|
fastifyMiddlewareError.unsubscribe(blockOnDatadogRaspAbortError)
|
|
132
138
|
routerMiddlewareError.unsubscribe(blockOnDatadogRaspAbortError)
|
|
139
|
+
nextRequestStart.unsubscribe(onNextRequestStart)
|
|
133
140
|
}
|
|
134
141
|
|
|
135
142
|
module.exports = {
|
|
@@ -77,13 +77,13 @@ function analyzeLfi (ctx) {
|
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
function analyzeLfiPath (path, req, res, abortController) {
|
|
80
|
-
const
|
|
80
|
+
const subcontextData = {
|
|
81
81
|
[FS_OPERATION_PATH]: path,
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
const raspRule = { type: RULE_TYPES.LFI }
|
|
85
85
|
|
|
86
|
-
const result = waf.
|
|
86
|
+
const result = waf.runSubContext(subcontextData, raspRule, undefined, req)
|
|
87
87
|
handleResult(result, req, res, abortController, config, raspRule)
|
|
88
88
|
}
|
|
89
89
|
|
|
@@ -65,37 +65,27 @@ function analyzeSqlInjection (query, dbSystem, abortController) {
|
|
|
65
65
|
}
|
|
66
66
|
executedQueries.add(query)
|
|
67
67
|
|
|
68
|
-
const
|
|
68
|
+
const subcontextData = {
|
|
69
69
|
[addresses.DB_STATEMENT]: query,
|
|
70
70
|
[addresses.DB_SYSTEM]: dbSystem,
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
const raspRule = { type: RULE_TYPES.SQL_INJECTION }
|
|
74
74
|
|
|
75
|
-
const result = waf.
|
|
75
|
+
const result = waf.runSubContext(subcontextData, raspRule)
|
|
76
76
|
|
|
77
77
|
handleResult(result, req, web.getContext(req)?.res, abortController, config, raspRule)
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
function
|
|
81
|
-
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
function hasAddressesObjectInputAddress (addressesObject) {
|
|
85
|
-
return addressesObject && Object.keys(addressesObject)
|
|
86
|
-
.some(address => address.startsWith('server.request') || address.startsWith('graphql.server'))
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
function clearQuerySet ({ payload }) {
|
|
90
|
-
if (!payload) return
|
|
91
|
-
|
|
92
|
-
const req = getActiveRequest()
|
|
93
|
-
if (!req) return
|
|
80
|
+
function clearQuerySet ({ req, payload }) {
|
|
81
|
+
if (!req || !payload) return
|
|
94
82
|
|
|
95
83
|
const executedQueries = reqQueryMap.get(req)
|
|
96
84
|
if (!executedQueries) return
|
|
97
85
|
|
|
98
|
-
|
|
86
|
+
const hasInput = Object.keys(payload)
|
|
87
|
+
.some(address => address.startsWith('server.request') || address.startsWith('graphql.server'))
|
|
88
|
+
if (hasInput) {
|
|
99
89
|
executedQueries.clear()
|
|
100
90
|
}
|
|
101
91
|
}
|