@depup/dd-trace 5.97.0-depup.0 → 6.5.0-depup.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 +89 -104
- package/README.electron.md +7 -0
- package/README.md +2 -2
- package/changes.json +1 -1
- package/ci/diagnose.js +2100 -0
- package/ci/init.js +46 -5
- package/ci/runbook.md +198 -0
- package/ci/test-optimization-validation/approval-artifacts.js +143 -0
- package/ci/test-optimization-validation/approval.js +299 -0
- package/ci/test-optimization-validation/artifact-id.js +20 -0
- package/ci/test-optimization-validation/bounded-json.js +121 -0
- package/ci/test-optimization-validation/ci-command-candidate.js +83 -0
- package/ci/test-optimization-validation/ci-discovery.js +181 -0
- package/ci/test-optimization-validation/ci-remediation.js +210 -0
- package/ci/test-optimization-validation/cli.js +903 -0
- package/ci/test-optimization-validation/command-blocker.js +81 -0
- package/ci/test-optimization-validation/command-output-policy.js +206 -0
- package/ci/test-optimization-validation/command-runner.js +707 -0
- package/ci/test-optimization-validation/command-suitability.js +471 -0
- package/ci/test-optimization-validation/executable-approval.js +48 -0
- package/ci/test-optimization-validation/executable.js +480 -0
- package/ci/test-optimization-validation/generated-file-policy.js +63 -0
- package/ci/test-optimization-validation/generated-files.js +351 -0
- package/ci/test-optimization-validation/generated-verifier.js +196 -0
- package/ci/test-optimization-validation/init-probe-preload.js +163 -0
- package/ci/test-optimization-validation/init-probe.js +246 -0
- package/ci/test-optimization-validation/late-initialization.js +63 -0
- package/ci/test-optimization-validation/local-command.js +163 -0
- package/ci/test-optimization-validation/manifest-loader.js +133 -0
- package/ci/test-optimization-validation/manifest-scaffold.js +738 -0
- package/ci/test-optimization-validation/manifest-schema.js +862 -0
- package/ci/test-optimization-validation/offline-fixtures.js +327 -0
- package/ci/test-optimization-validation/offline-output.js +406 -0
- package/ci/test-optimization-validation/payload-normalizer.js +72 -0
- package/ci/test-optimization-validation/plan-writer.js +1120 -0
- package/ci/test-optimization-validation/preflight-runner.js +114 -0
- package/ci/test-optimization-validation/redaction.js +331 -0
- package/ci/test-optimization-validation/report-writer.js +1508 -0
- package/ci/test-optimization-validation/safe-files.js +203 -0
- package/ci/test-optimization-validation/scenarios/auto-test-retries.js +159 -0
- package/ci/test-optimization-validation/scenarios/basic-reporting.js +657 -0
- package/ci/test-optimization-validation/scenarios/ci-wiring.js +780 -0
- package/ci/test-optimization-validation/scenarios/early-flake-detection.js +141 -0
- package/ci/test-optimization-validation/scenarios/helpers.js +539 -0
- package/ci/test-optimization-validation/scenarios/test-management.js +218 -0
- package/ci/test-optimization-validation/setup-runner.js +97 -0
- package/ci/test-optimization-validation/static-diagnosis.js +159 -0
- package/ci/test-optimization-validation/test-output.js +129 -0
- package/ci/test-optimization-validation-manifest.schema.json +1 -0
- package/ci/validate-test-optimization.js +3 -0
- package/ci/vitest-no-worker-init-setup.mjs +430 -0
- package/ext/exporters.js +2 -0
- package/ext/tags.js +3 -0
- package/index.d.ts +436 -252
- package/index.electron.js +3 -0
- package/init.js +18 -0
- package/initialize.mjs +10 -9
- package/loader-hook.mjs +170 -53
- package/openfeature.d.ts +1 -0
- package/openfeature.js +4 -0
- package/package.json +118 -80
- package/packages/datadog-core/src/storage.js +47 -48
- package/packages/datadog-esbuild/index.js +32 -1
- package/packages/datadog-esbuild/src/utils.js +46 -3
- package/packages/datadog-instrumentations/src/aerospike.js +3 -3
- package/packages/datadog-instrumentations/src/ai.js +137 -76
- package/packages/datadog-instrumentations/src/amqplib.js +6 -7
- package/packages/datadog-instrumentations/src/anthropic.js +10 -10
- package/packages/datadog-instrumentations/src/apollo-server-core.js +3 -3
- package/packages/datadog-instrumentations/src/apollo-server.js +10 -18
- package/packages/datadog-instrumentations/src/avsc.js +6 -6
- package/packages/datadog-instrumentations/src/aws-durable-execution-sdk-js-context-methods.js +18 -0
- package/packages/datadog-instrumentations/src/aws-durable-execution-sdk-js.js +111 -0
- package/packages/datadog-instrumentations/src/aws-sdk.js +172 -72
- package/packages/datadog-instrumentations/src/azure-cosmos.js +7 -0
- package/packages/datadog-instrumentations/src/azure-durable-functions.js +8 -8
- package/packages/datadog-instrumentations/src/azure-functions.js +3 -0
- package/packages/datadog-instrumentations/src/bluebird.js +2 -2
- package/packages/datadog-instrumentations/src/body-parser.js +5 -2
- package/packages/datadog-instrumentations/src/cassandra-driver.js +12 -9
- package/packages/datadog-instrumentations/src/child_process.js +16 -16
- package/packages/datadog-instrumentations/src/claude-agent-sdk.js +587 -0
- package/packages/datadog-instrumentations/src/confluentinc-kafka-javascript.js +41 -24
- package/packages/datadog-instrumentations/src/connect.js +14 -12
- package/packages/datadog-instrumentations/src/cookie-parser.js +5 -4
- package/packages/datadog-instrumentations/src/cookie.js +9 -3
- package/packages/datadog-instrumentations/src/couchbase.js +73 -238
- package/packages/datadog-instrumentations/src/crypto.js +49 -4
- package/packages/datadog-instrumentations/src/cucumber-worker-threads.js +25 -0
- package/packages/datadog-instrumentations/src/cucumber.js +762 -189
- package/packages/datadog-instrumentations/src/cypress-config.js +547 -93
- package/packages/datadog-instrumentations/src/cypress.js +5 -3
- package/packages/datadog-instrumentations/src/dns.js +60 -59
- package/packages/datadog-instrumentations/src/elasticsearch.js +9 -12
- package/packages/datadog-instrumentations/src/electron/preload.js +42 -0
- package/packages/datadog-instrumentations/src/electron.js +240 -0
- package/packages/datadog-instrumentations/src/express-mongo-sanitize.js +11 -9
- package/packages/datadog-instrumentations/src/express-session.js +14 -13
- package/packages/datadog-instrumentations/src/express.js +52 -30
- package/packages/datadog-instrumentations/src/fastify.js +166 -87
- package/packages/datadog-instrumentations/src/fetch.js +5 -5
- package/packages/datadog-instrumentations/src/fs.js +22 -20
- package/packages/datadog-instrumentations/src/google-cloud-pubsub.js +5 -7
- package/packages/datadog-instrumentations/src/google-genai.js +4 -4
- package/packages/datadog-instrumentations/src/graphql.js +26 -362
- package/packages/datadog-instrumentations/src/grpc/client.js +48 -32
- package/packages/datadog-instrumentations/src/grpc/server.js +20 -2
- package/packages/datadog-instrumentations/src/hapi.js +2 -2
- package/packages/datadog-instrumentations/src/helpers/callback-instrumentor.js +74 -0
- package/packages/datadog-instrumentations/src/helpers/check-require-cache.js +85 -9
- package/packages/datadog-instrumentations/src/helpers/hook.js +31 -7
- package/packages/datadog-instrumentations/src/helpers/hooks.js +12 -0
- package/packages/datadog-instrumentations/src/helpers/instrument.js +36 -3
- package/packages/datadog-instrumentations/src/helpers/kafka.js +58 -0
- package/packages/datadog-instrumentations/src/helpers/optional-peer-bundler.js +65 -0
- package/packages/datadog-instrumentations/src/helpers/promise-instrumentor.js +42 -0
- package/packages/datadog-instrumentations/src/helpers/promise.js +2 -2
- package/packages/datadog-instrumentations/src/helpers/register.js +7 -5
- package/packages/datadog-instrumentations/src/helpers/rewriter/compiler.js +13 -5
- package/packages/datadog-instrumentations/src/helpers/rewriter/index.js +24 -7
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/ai.js +6 -6
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/aws-durable-execution-sdk-js.js +31 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/azure-cosmos.js +50 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/claude-agent-sdk.js +17 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/graphql.js +201 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/index.js +7 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/langgraph.js +4 -2
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/mercurius.js +31 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/modelcontextprotocol-sdk.js +35 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/playwright.js +111 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/loader.mjs +18 -2
- package/packages/datadog-instrumentations/src/helpers/rewriter/transforms.js +49 -224
- package/packages/datadog-instrumentations/src/helpers/router-helper.js +8 -8
- package/packages/datadog-instrumentations/src/hono.js +71 -9
- package/packages/datadog-instrumentations/src/http/client.js +48 -24
- package/packages/datadog-instrumentations/src/http/server.js +75 -29
- package/packages/datadog-instrumentations/src/http2/client.js +15 -12
- package/packages/datadog-instrumentations/src/http2/server.js +156 -23
- package/packages/datadog-instrumentations/src/ioredis.js +17 -14
- package/packages/datadog-instrumentations/src/iovalkey.js +1 -2
- package/packages/datadog-instrumentations/src/jest/bail-reporter.js +42 -0
- package/packages/datadog-instrumentations/src/jest/coverage-backfill.js +163 -0
- package/packages/datadog-instrumentations/src/jest.js +1809 -401
- package/packages/datadog-instrumentations/src/kafkajs.js +284 -170
- package/packages/datadog-instrumentations/src/knex.js +17 -17
- package/packages/datadog-instrumentations/src/koa.js +15 -14
- package/packages/datadog-instrumentations/src/ldapjs.js +5 -5
- package/packages/datadog-instrumentations/src/light-my-request.js +2 -2
- package/packages/datadog-instrumentations/src/limitd-client.js +4 -4
- package/packages/datadog-instrumentations/src/lodash.js +4 -4
- package/packages/datadog-instrumentations/src/mariadb.js +18 -16
- package/packages/datadog-instrumentations/src/memcached.js +4 -3
- package/packages/datadog-instrumentations/src/mercurius.js +11 -0
- package/packages/datadog-instrumentations/src/microgateway-core.js +2 -2
- package/packages/datadog-instrumentations/src/mocha/common.js +7 -4
- package/packages/datadog-instrumentations/src/mocha/main.js +557 -120
- package/packages/datadog-instrumentations/src/mocha/utils.js +531 -135
- package/packages/datadog-instrumentations/src/mocha/worker.js +27 -9
- package/packages/datadog-instrumentations/src/modelcontextprotocol-sdk.js +254 -0
- package/packages/datadog-instrumentations/src/mongodb-core.js +43 -31
- package/packages/datadog-instrumentations/src/mongodb.js +82 -8
- package/packages/datadog-instrumentations/src/mongoose.js +46 -37
- package/packages/datadog-instrumentations/src/mquery.js +7 -7
- package/packages/datadog-instrumentations/src/multer.js +5 -4
- package/packages/datadog-instrumentations/src/mysql.js +17 -17
- package/packages/datadog-instrumentations/src/mysql2.js +39 -5
- package/packages/datadog-instrumentations/src/nats.js +182 -0
- package/packages/datadog-instrumentations/src/net.js +19 -11
- package/packages/datadog-instrumentations/src/next.js +68 -10
- package/packages/datadog-instrumentations/src/nyc.js +43 -8
- package/packages/datadog-instrumentations/src/openai.js +124 -38
- package/packages/datadog-instrumentations/src/oracledb.js +12 -7
- package/packages/datadog-instrumentations/src/otel-sdk-trace.js +27 -6
- package/packages/datadog-instrumentations/src/passport-utils.js +5 -5
- package/packages/datadog-instrumentations/src/path-to-regexp.js +44 -0
- package/packages/datadog-instrumentations/src/pg.js +58 -25
- package/packages/datadog-instrumentations/src/pino.js +25 -41
- package/packages/datadog-instrumentations/src/playwright-browser-scripts.js +27 -0
- package/packages/datadog-instrumentations/src/playwright.js +1229 -356
- package/packages/datadog-instrumentations/src/process.js +3 -0
- package/packages/datadog-instrumentations/src/protobufjs.js +16 -16
- package/packages/datadog-instrumentations/src/redis.js +28 -15
- package/packages/datadog-instrumentations/src/restify.js +6 -5
- package/packages/datadog-instrumentations/src/router.js +253 -87
- package/packages/datadog-instrumentations/src/selenium.js +53 -28
- package/packages/datadog-instrumentations/src/stripe.js +47 -33
- package/packages/datadog-instrumentations/src/tedious.js +28 -0
- package/packages/datadog-instrumentations/src/vitest-main-no-worker-init.js +1297 -0
- package/packages/datadog-instrumentations/src/vitest-main.js +1590 -0
- package/packages/datadog-instrumentations/src/vitest-util.js +251 -0
- package/packages/datadog-instrumentations/src/vitest-worker.js +822 -0
- package/packages/datadog-instrumentations/src/vitest.js +11 -1262
- package/packages/datadog-instrumentations/src/winston.js +4 -4
- package/packages/datadog-instrumentations/src/ws.js +9 -8
- package/packages/datadog-instrumentations/src/zlib.js +29 -0
- package/packages/datadog-plugin-ai/src/index.js +1 -1
- package/packages/datadog-plugin-ai/src/tracing.js +66 -3
- package/packages/datadog-plugin-ai/src/utils.js +17 -4
- package/packages/datadog-plugin-apollo/src/gateway/request.js +1 -21
- package/packages/datadog-plugin-avsc/src/schema_iterator.js +3 -3
- package/packages/datadog-plugin-aws-durable-execution-sdk-js/src/checkpoint.js +31 -0
- package/packages/datadog-plugin-aws-durable-execution-sdk-js/src/client.js +55 -0
- package/packages/datadog-plugin-aws-durable-execution-sdk-js/src/context.js +123 -0
- package/packages/datadog-plugin-aws-durable-execution-sdk-js/src/handler.js +129 -0
- package/packages/datadog-plugin-aws-durable-execution-sdk-js/src/index.js +19 -0
- package/packages/datadog-plugin-aws-durable-execution-sdk-js/src/trace-checkpoint.js +224 -0
- package/packages/datadog-plugin-aws-durable-execution-sdk-js/src/util.js +80 -0
- package/packages/datadog-plugin-aws-sdk/src/base.js +86 -50
- package/packages/datadog-plugin-aws-sdk/src/services/bedrockruntime/tracing.js +1 -1
- package/packages/datadog-plugin-aws-sdk/src/services/bedrockruntime/utils.js +218 -4
- package/packages/datadog-plugin-aws-sdk/src/services/cloudwatchlogs.js +1 -1
- package/packages/datadog-plugin-aws-sdk/src/services/dynamodb.js +2 -1
- package/packages/datadog-plugin-aws-sdk/src/services/eventbridge.js +59 -14
- package/packages/datadog-plugin-aws-sdk/src/services/kinesis.js +174 -75
- package/packages/datadog-plugin-aws-sdk/src/services/lambda.js +34 -23
- package/packages/datadog-plugin-aws-sdk/src/services/redshift.js +2 -1
- package/packages/datadog-plugin-aws-sdk/src/services/s3.js +1 -1
- package/packages/datadog-plugin-aws-sdk/src/services/sns.js +26 -26
- package/packages/datadog-plugin-aws-sdk/src/services/sqs.js +187 -101
- package/packages/datadog-plugin-aws-sdk/src/services/stepfunctions.js +20 -18
- package/packages/datadog-plugin-aws-sdk/src/util.js +2 -2
- package/packages/datadog-plugin-azure-cosmos/src/index.js +144 -0
- package/packages/datadog-plugin-azure-event-hubs/src/producer.js +8 -15
- package/packages/datadog-plugin-azure-functions/src/index.js +7 -3
- package/packages/datadog-plugin-azure-service-bus/src/producer.js +5 -10
- package/packages/datadog-plugin-bullmq/src/consumer.js +5 -4
- package/packages/datadog-plugin-bullmq/src/filter.js +35 -0
- package/packages/datadog-plugin-bullmq/src/producer.js +121 -33
- package/packages/datadog-plugin-bunyan/src/index.js +28 -0
- package/packages/datadog-plugin-child_process/src/index.js +13 -2
- package/packages/datadog-plugin-child_process/src/scrub-cmd-params.js +6 -6
- package/packages/datadog-plugin-claude-agent-sdk/src/index.js +31 -0
- package/packages/datadog-plugin-claude-agent-sdk/src/tracing.js +107 -0
- package/packages/datadog-plugin-claude-agent-sdk/src/util.js +15 -0
- package/packages/datadog-plugin-couchbase/src/index.js +58 -52
- package/packages/datadog-plugin-cucumber/src/index.js +47 -29
- package/packages/datadog-plugin-cypress/src/cypress-plugin.js +929 -98
- package/packages/datadog-plugin-cypress/src/index.js +109 -2
- package/packages/datadog-plugin-cypress/src/plugin.js +6 -14
- package/packages/datadog-plugin-cypress/src/source-map-utils.js +48 -1
- package/packages/datadog-plugin-cypress/src/support.js +272 -51
- package/packages/datadog-plugin-dd-trace-api/src/index.js +1 -1
- package/packages/datadog-plugin-dns/src/lookup.js +8 -6
- package/packages/datadog-plugin-elasticsearch/src/index.js +28 -8
- package/packages/datadog-plugin-electron/src/index.js +17 -0
- package/packages/datadog-plugin-electron/src/ipc.js +143 -0
- package/packages/datadog-plugin-electron/src/net.js +82 -0
- package/packages/datadog-plugin-express/src/code_origin.js +1 -1
- package/packages/datadog-plugin-fastify/src/code_origin.js +1 -1
- package/packages/datadog-plugin-fs/src/index.js +2 -1
- package/packages/datadog-plugin-google-cloud-pubsub/src/consumer.js +2 -5
- package/packages/datadog-plugin-google-cloud-pubsub/src/producer.js +27 -18
- package/packages/datadog-plugin-google-cloud-pubsub/src/pubsub-push-subscription.js +5 -8
- package/packages/datadog-plugin-graphql/src/execute.js +748 -34
- package/packages/datadog-plugin-graphql/src/index.js +43 -9
- package/packages/datadog-plugin-graphql/src/parse.js +45 -4
- package/packages/datadog-plugin-graphql/src/request.js +135 -0
- package/packages/datadog-plugin-graphql/src/tools/signature.js +32 -7
- package/packages/datadog-plugin-graphql/src/tools/transforms.js +118 -100
- package/packages/datadog-plugin-graphql/src/utils.js +261 -3
- package/packages/datadog-plugin-graphql/src/validate.js +54 -8
- package/packages/datadog-plugin-grpc/src/client.js +7 -8
- package/packages/datadog-plugin-grpc/src/server.js +1 -1
- package/packages/datadog-plugin-grpc/src/util.js +57 -22
- package/packages/datadog-plugin-http/src/client.js +12 -14
- package/packages/datadog-plugin-http/src/index.js +6 -8
- package/packages/datadog-plugin-http/src/server.js +63 -20
- package/packages/datadog-plugin-http2/src/client.js +7 -4
- package/packages/datadog-plugin-http2/src/server.js +48 -8
- package/packages/datadog-plugin-jest/src/index.js +133 -67
- package/packages/datadog-plugin-jest/src/util.js +37 -16
- package/packages/datadog-plugin-kafkajs/src/batch-consumer.js +1 -1
- package/packages/datadog-plugin-kafkajs/src/consumer.js +2 -9
- package/packages/datadog-plugin-kafkajs/src/producer.js +37 -8
- package/packages/datadog-plugin-langchain/src/handlers/embedding.js +2 -1
- package/packages/datadog-plugin-langchain/src/handlers/language_models.js +2 -1
- package/packages/datadog-plugin-langchain/src/tokens.js +2 -2
- package/packages/datadog-plugin-langgraph/src/stream.js +1 -1
- package/packages/datadog-plugin-memcached/src/index.js +1 -1
- package/packages/datadog-plugin-mocha/src/index.js +66 -20
- package/packages/datadog-plugin-modelcontextprotocol-sdk/src/index.js +24 -0
- package/packages/datadog-plugin-modelcontextprotocol-sdk/src/tracing.js +173 -0
- package/packages/datadog-plugin-modelcontextprotocol-sdk/src/utils.js +30 -0
- package/packages/datadog-plugin-mongodb-core/src/bulk-write.js +43 -0
- package/packages/datadog-plugin-mongodb-core/src/index.js +8 -206
- package/packages/datadog-plugin-mongodb-core/src/query.js +452 -0
- package/packages/datadog-plugin-mysql/src/index.js +9 -4
- package/packages/datadog-plugin-nats/src/consumer.js +43 -0
- package/packages/datadog-plugin-nats/src/index.js +20 -0
- package/packages/datadog-plugin-nats/src/producer.js +62 -0
- package/packages/datadog-plugin-nats/src/util.js +33 -0
- package/packages/datadog-plugin-next/src/index.js +12 -4
- package/packages/datadog-plugin-openai/src/services.js +4 -3
- package/packages/datadog-plugin-openai/src/tracing.js +27 -25
- package/packages/datadog-plugin-oracledb/src/index.js +13 -2
- package/packages/datadog-plugin-pg/src/index.js +13 -3
- package/packages/datadog-plugin-pino/src/index.js +42 -0
- package/packages/datadog-plugin-playwright/src/index.js +195 -72
- package/packages/datadog-plugin-protobufjs/src/schema_iterator.js +3 -3
- package/packages/datadog-plugin-redis/src/index.js +54 -25
- package/packages/datadog-plugin-rhea/src/producer.js +1 -1
- package/packages/datadog-plugin-router/src/index.js +55 -44
- package/packages/datadog-plugin-selenium/src/index.js +5 -36
- package/packages/datadog-plugin-tedious/src/index.js +1 -1
- package/packages/datadog-plugin-undici/src/index.js +24 -2
- package/packages/datadog-plugin-vitest/src/index.js +160 -90
- package/packages/datadog-plugin-winston/src/index.js +30 -0
- package/packages/datadog-plugin-ws/src/close.js +5 -2
- package/packages/datadog-plugin-ws/src/producer.js +4 -1
- package/packages/datadog-plugin-ws/src/receiver.js +4 -2
- package/packages/datadog-plugin-ws/src/server.js +2 -1
- package/packages/datadog-shimmer/src/shimmer.js +101 -39
- package/packages/datadog-webpack/index.js +17 -1
- package/packages/datadog-webpack/src/optional-peer-loader.js +17 -0
- package/packages/dd-trace/index.electron.js +3 -0
- package/packages/dd-trace/index.js +2 -36
- package/packages/dd-trace/src/aiguard/channels.js +7 -0
- package/packages/dd-trace/src/aiguard/index.js +16 -34
- package/packages/dd-trace/src/aiguard/integrations/evaluate.js +46 -0
- package/packages/dd-trace/src/aiguard/integrations/index.js +34 -0
- package/packages/dd-trace/src/aiguard/integrations/openai.js +80 -0
- package/packages/dd-trace/src/aiguard/integrations/vercel-ai.js +92 -0
- package/packages/dd-trace/src/aiguard/messages/openai.js +382 -0
- package/packages/{datadog-instrumentations/src/helpers/ai-messages.js → dd-trace/src/aiguard/messages/vercel-ai.js} +30 -27
- package/packages/dd-trace/src/aiguard/sdk.js +148 -55
- package/packages/dd-trace/src/aiguard/tags.js +26 -10
- package/packages/dd-trace/src/appsec/api_security/index.js +55 -0
- package/packages/dd-trace/src/appsec/api_security/sampler.js +147 -0
- package/packages/dd-trace/src/appsec/blocked_templates.js +4 -3
- package/packages/dd-trace/src/appsec/blocking.js +82 -42
- package/packages/dd-trace/src/appsec/channels.js +5 -1
- package/packages/dd-trace/src/appsec/downstream_requests.js +116 -62
- package/packages/dd-trace/src/appsec/graphql.js +20 -17
- package/packages/dd-trace/src/appsec/iast/analyzers/hardcoded-password-rules.js +1 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/hardcoded-secret-rules.js +81 -81
- package/packages/dd-trace/src/appsec/iast/analyzers/nosql-injection-mongodb-analyzer.js +23 -23
- package/packages/dd-trace/src/appsec/iast/index.js +3 -2
- package/packages/dd-trace/src/appsec/iast/security-controls/index.js +4 -4
- package/packages/dd-trace/src/appsec/iast/taint-tracking/plugin.js +2 -2
- package/packages/dd-trace/src/appsec/iast/taint-tracking/plugins/kafka.js +2 -2
- package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter.js +4 -4
- package/packages/dd-trace/src/appsec/iast/taint-tracking/taint-tracking-impl.js +2 -2
- package/packages/dd-trace/src/appsec/iast/telemetry/index.js +2 -1
- package/packages/dd-trace/src/appsec/iast/telemetry/span-tags.js +3 -1
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-analyzers/ldap-sensitive-analyzer.js +54 -12
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-analyzers/url-sensitive-analyzer.js +5 -1
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-handler.js +31 -4
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/index.js +1 -3
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/utils.js +83 -48
- package/packages/dd-trace/src/appsec/iast/vulnerability-reporter.js +1 -1
- package/packages/dd-trace/src/appsec/index.js +65 -47
- package/packages/dd-trace/src/appsec/lambda.js +135 -0
- package/packages/dd-trace/src/appsec/rasp/command_injection.js +4 -5
- package/packages/dd-trace/src/appsec/rasp/lfi.js +8 -4
- package/packages/dd-trace/src/appsec/rasp/sql_injection.js +5 -10
- package/packages/dd-trace/src/appsec/rasp/ssrf.js +26 -18
- package/packages/dd-trace/src/appsec/recommended.json +2438 -13
- package/packages/dd-trace/src/appsec/reporter.js +87 -28
- package/packages/dd-trace/src/appsec/rule_manager.js +4 -2
- package/packages/dd-trace/src/appsec/sdk/set_user.js +1 -1
- package/packages/dd-trace/src/appsec/sdk/track_event.js +5 -5
- package/packages/dd-trace/src/appsec/sdk/user_blocking.js +7 -11
- package/packages/dd-trace/src/appsec/sdk/utils.js +5 -3
- package/packages/dd-trace/src/appsec/store.js +50 -0
- package/packages/dd-trace/src/appsec/telemetry/api_security.js +34 -0
- package/packages/dd-trace/src/appsec/telemetry/index.js +27 -1
- package/packages/dd-trace/src/appsec/user_tracking.js +5 -4
- package/packages/dd-trace/src/appsec/waf/index.js +19 -9
- package/packages/dd-trace/src/appsec/waf/waf_context_wrapper.js +35 -20
- package/packages/dd-trace/src/appsec/waf/waf_manager.js +1 -1
- package/packages/dd-trace/src/azure_metadata.js +19 -7
- package/packages/dd-trace/src/baggage.js +32 -13
- package/packages/dd-trace/src/bootstrap.js +39 -0
- package/packages/dd-trace/src/ci-visibility/dynamic-instrumentation/index.js +123 -33
- package/packages/dd-trace/src/ci-visibility/dynamic-instrumentation/worker/index.js +122 -24
- package/packages/dd-trace/src/ci-visibility/early-flake-detection/get-known-tests.js +22 -7
- package/packages/dd-trace/src/ci-visibility/exporters/agent-proxy/index.js +5 -2
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/coverage-writer.js +2 -2
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/di-logs-writer.js +2 -2
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/index.js +6 -2
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/writer.js +2 -2
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/index.js +160 -0
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/msgpack-to-json.js +288 -0
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/payload-projection.js +84 -0
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/sink.js +369 -0
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/writer.js +60 -0
- package/packages/dd-trace/src/ci-visibility/exporters/ci-visibility-exporter.js +188 -27
- package/packages/dd-trace/src/ci-visibility/exporters/git/git_metadata.js +3 -4
- package/packages/dd-trace/src/ci-visibility/exporters/test-worker/index.js +28 -10
- package/packages/dd-trace/src/ci-visibility/exporters/test-worker/writer.js +22 -0
- package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +110 -22
- package/packages/dd-trace/src/ci-visibility/lage.js +2 -1
- package/packages/dd-trace/src/ci-visibility/log-submission/log-submission-plugin.js +4 -5
- package/packages/dd-trace/src/ci-visibility/requests/fs-cache.js +4 -5
- package/packages/dd-trace/src/ci-visibility/requests/get-library-configuration.js +73 -55
- package/packages/dd-trace/src/ci-visibility/requests/request.js +14 -50
- package/packages/dd-trace/src/ci-visibility/requests/upload-coverage-report.js +10 -6
- package/packages/dd-trace/src/ci-visibility/requests/upload-test-screenshot.js +156 -0
- package/packages/dd-trace/src/ci-visibility/rum.js +7 -0
- package/packages/dd-trace/src/ci-visibility/test-api-manual/test-api-manual-plugin.js +9 -3
- package/packages/dd-trace/src/ci-visibility/test-management/get-test-management-tests.js +24 -6
- package/packages/dd-trace/src/ci-visibility/test-optimization-cache.js +70 -6
- package/packages/dd-trace/src/ci-visibility/test-optimization-http-cache-schema.js +256 -0
- package/packages/dd-trace/src/ci-visibility/test-optimization-http-cache.js +451 -0
- package/packages/dd-trace/src/ci-visibility/test-screenshot.js +90 -0
- package/packages/dd-trace/src/config/config-types.d.ts +8 -6
- package/packages/dd-trace/src/config/defaults.js +71 -44
- package/packages/dd-trace/src/config/generated-config-types.d.ts +692 -131
- package/packages/dd-trace/src/config/git_properties.js +2 -2
- package/packages/dd-trace/src/config/helper.js +140 -33
- package/packages/dd-trace/src/config/index.js +127 -131
- package/packages/dd-trace/src/config/major-overrides.js +100 -0
- package/packages/dd-trace/src/config/normalize-service.js +31 -0
- package/packages/dd-trace/src/config/parsers.js +138 -10
- package/packages/dd-trace/src/config/remote_config.js +1 -1
- package/packages/dd-trace/src/config/supported-configurations.json +460 -203
- package/packages/dd-trace/src/constants.js +15 -0
- package/packages/dd-trace/src/crashtracking/crashtracker.js +18 -6
- package/packages/dd-trace/src/datastreams/checkpointer.js +6 -12
- package/packages/dd-trace/src/datastreams/context.js +4 -2
- package/packages/dd-trace/src/datastreams/encoding.js +39 -28
- package/packages/dd-trace/src/datastreams/index.js +2 -1
- package/packages/dd-trace/src/datastreams/manager.js +1 -1
- package/packages/dd-trace/src/datastreams/pathway.js +35 -30
- package/packages/dd-trace/src/datastreams/processor.js +31 -22
- package/packages/dd-trace/src/datastreams/size.js +6 -2
- package/packages/dd-trace/src/datastreams/writer.js +15 -6
- package/packages/dd-trace/src/debugger/config.js +9 -4
- package/packages/dd-trace/src/debugger/devtools_client/breakpoints.js +49 -35
- package/packages/dd-trace/src/debugger/devtools_client/condition.js +5 -8
- package/packages/dd-trace/src/debugger/devtools_client/config.js +3 -2
- package/packages/dd-trace/src/debugger/devtools_client/index.js +33 -71
- package/packages/dd-trace/src/debugger/devtools_client/probe_sampler.js +83 -0
- package/packages/dd-trace/src/debugger/devtools_client/send.js +27 -6
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/collector.js +2 -2
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/processor.js +5 -2
- package/packages/dd-trace/src/debugger/devtools_client/snapshot-pruner.js +1 -0
- package/packages/dd-trace/src/debugger/devtools_client/source-maps.js +1 -1
- package/packages/dd-trace/src/debugger/devtools_client/state.js +3 -1
- package/packages/dd-trace/src/debugger/index.js +13 -9
- package/packages/dd-trace/src/debugger/probe_sampler.js +112 -0
- package/packages/dd-trace/src/debugger/probe_sampler_constants.js +19 -0
- package/packages/dd-trace/src/dogstatsd.js +34 -28
- package/packages/dd-trace/src/encode/0.4.js +829 -268
- package/packages/dd-trace/src/encode/0.5.js +158 -22
- package/packages/dd-trace/src/encode/agentless-ci-visibility.js +141 -65
- package/packages/dd-trace/src/encode/agentless-json.js +12 -6
- package/packages/dd-trace/src/encode/coverage-ci-visibility.js +52 -15
- package/packages/dd-trace/src/encode/span-stats.js +19 -16
- package/packages/dd-trace/src/encode/tags-processors.js +30 -25
- package/packages/dd-trace/src/exporter.js +5 -1
- package/packages/dd-trace/src/exporters/agent/index.js +4 -5
- package/packages/dd-trace/src/exporters/agent/writer.js +1 -2
- package/packages/dd-trace/src/exporters/agentless/index.js +12 -13
- package/packages/dd-trace/src/exporters/agentless/intake.js +43 -0
- package/packages/dd-trace/src/exporters/agentless/writer.js +12 -11
- package/packages/dd-trace/src/exporters/common/agents.js +3 -1
- package/packages/dd-trace/src/exporters/common/buffering-exporter.js +3 -3
- package/packages/dd-trace/src/exporters/common/client-library-headers.js +21 -0
- package/packages/dd-trace/src/exporters/common/request.js +93 -44
- package/packages/dd-trace/src/exporters/common/retry.js +104 -0
- package/packages/dd-trace/src/exporters/common/url.js +48 -0
- package/packages/dd-trace/src/exporters/common/util.js +2 -2
- package/packages/dd-trace/src/exporters/common/writer.js +17 -1
- package/packages/dd-trace/src/exporters/electron/index.js +49 -0
- package/packages/dd-trace/src/exporters/span-stats/index.js +1 -2
- package/packages/dd-trace/src/exporters/span-stats/writer.js +1 -3
- package/packages/dd-trace/src/external-logger/src/index.js +2 -1
- package/packages/dd-trace/src/feature-registry.js +29 -0
- package/packages/dd-trace/src/git_metadata.js +68 -0
- package/packages/dd-trace/src/git_metadata_tagger.js +13 -5
- package/packages/dd-trace/src/guardrails/index.js +11 -6
- package/packages/dd-trace/src/guardrails/telemetry.js +40 -3
- package/packages/dd-trace/src/heap_snapshots.js +4 -4
- package/packages/dd-trace/src/id.js +46 -27
- package/packages/dd-trace/src/index.js +7 -8
- package/packages/dd-trace/src/lambda/handler-paths.js +52 -0
- package/packages/dd-trace/src/lambda/handler.js +2 -6
- package/packages/dd-trace/src/lambda/index.js +62 -14
- package/packages/dd-trace/src/lambda/runtime/patch.js +21 -46
- package/packages/dd-trace/src/llmobs/constants/tags.js +13 -0
- package/packages/dd-trace/src/llmobs/experiments/client.js +113 -0
- package/packages/dd-trace/src/llmobs/experiments/dataset.js +154 -0
- package/packages/dd-trace/src/llmobs/experiments/experiment.js +283 -0
- package/packages/dd-trace/src/llmobs/experiments/index.js +152 -0
- package/packages/dd-trace/src/llmobs/experiments/noop.js +30 -0
- package/packages/dd-trace/src/llmobs/experiments/result.js +34 -0
- package/packages/dd-trace/src/llmobs/index.js +37 -7
- package/packages/dd-trace/src/llmobs/noop.js +6 -0
- package/packages/dd-trace/src/llmobs/plugins/ai/ddTelemetry.js +403 -0
- package/packages/dd-trace/src/llmobs/plugins/ai/index.js +8 -395
- package/packages/dd-trace/src/llmobs/plugins/ai/util.js +119 -7
- package/packages/dd-trace/src/llmobs/plugins/ai/vercelTelemetry.js +380 -0
- package/packages/dd-trace/src/llmobs/plugins/{anthropic.js → anthropic/index.js} +32 -79
- package/packages/dd-trace/src/llmobs/plugins/anthropic/util.js +109 -0
- package/packages/dd-trace/src/llmobs/plugins/base.js +4 -4
- package/packages/dd-trace/src/llmobs/plugins/bedrockruntime.js +89 -37
- package/packages/dd-trace/src/llmobs/plugins/claude-agent-sdk/index.js +270 -0
- package/packages/dd-trace/src/llmobs/plugins/claude-agent-sdk/utils.js +10 -0
- package/packages/dd-trace/src/llmobs/plugins/genai/index.js +5 -1
- package/packages/dd-trace/src/llmobs/plugins/genai/util.js +81 -16
- package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/chain.js +3 -2
- package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/chat_model.js +3 -2
- package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/embedding.js +2 -1
- package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/index.js +1 -50
- package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/vectorstore.js +2 -1
- package/packages/dd-trace/src/llmobs/plugins/langchain/index.js +14 -8
- package/packages/dd-trace/src/llmobs/plugins/langchain/messages.js +76 -0
- package/packages/dd-trace/src/llmobs/plugins/langgraph/index.js +4 -29
- package/packages/dd-trace/src/llmobs/plugins/modelcontextprotocol-sdk/index.js +68 -0
- package/packages/dd-trace/src/llmobs/plugins/modelcontextprotocol-sdk/utils.js +57 -0
- package/packages/dd-trace/src/llmobs/plugins/openai/constants.js +8 -0
- package/packages/dd-trace/src/llmobs/plugins/openai/index.js +68 -64
- package/packages/dd-trace/src/llmobs/plugins/openai/utils.js +43 -0
- package/packages/dd-trace/src/llmobs/sdk.js +73 -35
- package/packages/dd-trace/src/llmobs/span_processor.js +90 -11
- package/packages/dd-trace/src/llmobs/tagger.js +197 -4
- package/packages/dd-trace/src/llmobs/telemetry.js +33 -2
- package/packages/dd-trace/src/llmobs/util.js +234 -9
- package/packages/dd-trace/src/llmobs/writers/base.js +11 -5
- package/packages/dd-trace/src/llmobs/writers/spans.js +1 -1
- package/packages/dd-trace/src/llmobs/writers/util.js +1 -2
- package/packages/dd-trace/src/log/index.js +19 -31
- package/packages/dd-trace/src/log/writer.js +3 -1
- package/packages/dd-trace/src/msgpack/chunk.js +430 -11
- package/packages/dd-trace/src/msgpack/index.js +101 -2
- package/packages/dd-trace/src/noop/proxy.js +5 -4
- package/packages/dd-trace/src/noop/span.js +3 -1
- package/packages/dd-trace/src/openfeature/agentless_configuration_source.js +322 -0
- package/packages/dd-trace/src/openfeature/configuration_source.js +90 -0
- package/packages/dd-trace/src/openfeature/encoding.js +70 -0
- package/packages/dd-trace/src/openfeature/eval-metrics-hook.js +103 -0
- package/packages/dd-trace/src/openfeature/flagging_provider.js +32 -16
- package/packages/dd-trace/src/openfeature/index.js +0 -2
- package/packages/dd-trace/src/openfeature/noop.js +41 -64
- package/packages/dd-trace/src/openfeature/register.js +35 -0
- package/packages/dd-trace/src/openfeature/remote_config.js +16 -14
- package/packages/dd-trace/src/openfeature/require-provider.js +18 -0
- package/packages/dd-trace/src/openfeature/span-enrichment-hook.js +143 -0
- package/packages/dd-trace/src/openfeature/span-enrichment.js +149 -0
- package/packages/dd-trace/src/openfeature/writers/base.js +3 -11
- package/packages/dd-trace/src/openfeature/writers/exposures.js +82 -70
- package/packages/dd-trace/src/openfeature/writers/util.js +1 -2
- package/packages/dd-trace/src/opentelemetry/active-span-proxy.js +42 -0
- package/packages/dd-trace/src/opentelemetry/bridge-span-base.js +107 -0
- package/packages/dd-trace/src/opentelemetry/context_manager.js +27 -13
- package/packages/dd-trace/src/opentelemetry/logs/index.js +6 -6
- package/packages/dd-trace/src/opentelemetry/logs/otlp_http_log_exporter.js +3 -2
- package/packages/dd-trace/src/opentelemetry/metrics/index.js +61 -12
- package/packages/dd-trace/src/opentelemetry/metrics/instruments.js +28 -14
- package/packages/dd-trace/src/opentelemetry/metrics/meter.js +7 -10
- package/packages/dd-trace/src/opentelemetry/metrics/otlp_http_metric_exporter.js +3 -2
- package/packages/dd-trace/src/opentelemetry/metrics/otlp_span_stats_exporter.js +40 -0
- package/packages/dd-trace/src/opentelemetry/metrics/otlp_span_stats_transformer.js +169 -0
- package/packages/dd-trace/src/opentelemetry/metrics/periodic_metric_reader.js +99 -5
- package/packages/dd-trace/src/opentelemetry/metrics/time.js +19 -0
- package/packages/dd-trace/src/opentelemetry/otlp/common.proto +2 -2
- package/packages/dd-trace/src/opentelemetry/otlp/logs.proto +1 -1
- package/packages/dd-trace/src/opentelemetry/otlp/logs_service.proto +1 -1
- package/packages/dd-trace/src/opentelemetry/otlp/metrics.proto +1 -1
- package/packages/dd-trace/src/opentelemetry/otlp/metrics_service.proto +1 -1
- package/packages/dd-trace/src/opentelemetry/otlp/otlp_http_exporter_base.js +56 -82
- package/packages/dd-trace/src/opentelemetry/otlp/otlp_transformer_base.js +1 -2
- package/packages/dd-trace/src/opentelemetry/otlp/protobuf_loader.js +14 -2
- package/packages/dd-trace/src/opentelemetry/otlp/trace.proto +358 -0
- package/packages/dd-trace/src/opentelemetry/otlp/trace_service.proto +78 -0
- package/packages/dd-trace/src/opentelemetry/span-ending-hook.js +10 -0
- package/packages/dd-trace/src/opentelemetry/span-helpers.js +325 -0
- package/packages/dd-trace/src/opentelemetry/span.js +64 -109
- package/packages/dd-trace/src/opentelemetry/span_context.js +1 -0
- package/packages/dd-trace/src/opentelemetry/span_processor.js +7 -5
- package/packages/dd-trace/src/opentelemetry/trace/index.js +75 -0
- package/packages/dd-trace/src/opentelemetry/trace/otlp_http_trace_exporter.js +75 -0
- package/packages/dd-trace/src/opentelemetry/trace/otlp_transformer.js +375 -0
- package/packages/dd-trace/src/opentelemetry/tracer.js +20 -69
- package/packages/dd-trace/src/opentelemetry/tracer_provider.js +33 -17
- package/packages/dd-trace/src/opentracing/propagation/log.js +28 -8
- package/packages/dd-trace/src/opentracing/propagation/text_map.js +278 -148
- package/packages/dd-trace/src/opentracing/propagation/text_map_dsm.js +11 -11
- package/packages/dd-trace/src/opentracing/propagation/tracestate.js +98 -32
- package/packages/dd-trace/src/opentracing/span.js +127 -73
- package/packages/dd-trace/src/opentracing/span_context.js +68 -3
- package/packages/dd-trace/src/opentracing/tracer.js +46 -19
- package/packages/dd-trace/src/payload-tagging/config/index.js +2 -2
- package/packages/dd-trace/src/plugin_manager.js +36 -14
- package/packages/dd-trace/src/plugins/apollo.js +3 -1
- package/packages/dd-trace/src/plugins/ci_plugin.js +407 -91
- package/packages/dd-trace/src/plugins/database.js +61 -18
- package/packages/dd-trace/src/plugins/index.js +14 -0
- package/packages/dd-trace/src/plugins/log_injection.js +56 -0
- package/packages/dd-trace/src/plugins/log_plugin.js +4 -44
- package/packages/dd-trace/src/plugins/outbound.js +1 -1
- package/packages/dd-trace/src/plugins/plugin.js +19 -28
- package/packages/dd-trace/src/plugins/storage.js +2 -2
- package/packages/dd-trace/src/plugins/tracing.js +70 -13
- package/packages/dd-trace/src/plugins/util/ci.js +127 -40
- package/packages/dd-trace/src/plugins/util/git-cache.js +23 -23
- package/packages/dd-trace/src/plugins/util/git.js +6 -3
- package/packages/dd-trace/src/plugins/util/http-otel-semantics.js +276 -0
- package/packages/dd-trace/src/plugins/util/inferred_proxy.js +29 -5
- package/packages/dd-trace/src/plugins/util/llm.js +6 -1
- package/packages/dd-trace/src/plugins/util/stacktrace.js +2 -2
- package/packages/dd-trace/src/plugins/util/test.js +950 -69
- package/packages/dd-trace/src/plugins/util/url.js +71 -5
- package/packages/dd-trace/src/plugins/util/user-provided-git.js +18 -16
- package/packages/dd-trace/src/plugins/util/web.js +116 -180
- package/packages/dd-trace/src/priority_sampler.js +12 -21
- package/packages/dd-trace/src/profiling/config.js +132 -212
- package/packages/dd-trace/src/profiling/constants.js +4 -7
- package/packages/dd-trace/src/profiling/exporter_cli.js +10 -10
- package/packages/dd-trace/src/profiling/exporters/agent.js +61 -28
- package/packages/dd-trace/src/profiling/exporters/event_serializer.js +45 -14
- package/packages/dd-trace/src/profiling/exporters/file.js +16 -5
- package/packages/dd-trace/src/profiling/oom.js +71 -0
- package/packages/dd-trace/src/profiling/profiler.js +84 -105
- package/packages/dd-trace/src/profiling/profilers/event_plugins/crypto.js +32 -0
- package/packages/dd-trace/src/profiling/profilers/event_plugins/zlib.js +19 -0
- package/packages/dd-trace/src/profiling/profilers/events.js +57 -13
- package/packages/dd-trace/src/profiling/profilers/space.js +27 -16
- package/packages/dd-trace/src/profiling/profilers/wall.js +49 -35
- package/packages/dd-trace/src/profiling/ssi-heuristics.js +3 -3
- package/packages/dd-trace/src/propagation-hash/index.js +1 -1
- package/packages/dd-trace/src/proxy.js +128 -37
- package/packages/dd-trace/src/rate_limiter.js +1 -1
- package/packages/dd-trace/src/remote_config/index.js +6 -5
- package/packages/dd-trace/src/remote_config/scheduler.js +1 -1
- package/packages/dd-trace/src/ritm.js +6 -3
- package/packages/dd-trace/src/runtime_metrics/client.js +30 -0
- package/packages/dd-trace/src/runtime_metrics/index.js +14 -4
- package/packages/dd-trace/src/runtime_metrics/otlp_runtime_metrics.js +284 -0
- package/packages/dd-trace/src/runtime_metrics/runtime_metrics.js +42 -41
- package/packages/dd-trace/src/sampling_rule.js +7 -7
- package/packages/dd-trace/src/scope.js +10 -15
- package/packages/dd-trace/src/serverless.js +6 -7
- package/packages/dd-trace/src/service-naming/extra-services.js +14 -0
- package/packages/dd-trace/src/service-naming/index.js +1 -1
- package/packages/dd-trace/src/service-naming/schemas/definition.js +4 -1
- package/packages/dd-trace/src/service-naming/schemas/util.js +48 -3
- package/packages/dd-trace/src/service-naming/schemas/v0/graphql.js +6 -0
- package/packages/dd-trace/src/service-naming/schemas/v0/messaging.js +61 -2
- package/packages/dd-trace/src/service-naming/schemas/v0/serverless.js +12 -0
- package/packages/dd-trace/src/service-naming/schemas/v0/storage.js +60 -0
- package/packages/dd-trace/src/service-naming/schemas/v0/web.js +25 -1
- package/packages/dd-trace/src/service-naming/schemas/v0/websocket.js +5 -0
- package/packages/dd-trace/src/service-naming/schemas/v1/graphql.js +8 -0
- package/packages/dd-trace/src/service-naming/schemas/v1/messaging.js +32 -0
- package/packages/dd-trace/src/service-naming/schemas/v1/serverless.js +12 -0
- package/packages/dd-trace/src/service-naming/schemas/v1/storage.js +17 -0
- package/packages/dd-trace/src/service-naming/schemas/v1/web.js +23 -3
- package/packages/dd-trace/src/service-naming/schemas/v1/websocket.js +6 -0
- package/packages/dd-trace/src/service-naming/source-resolver.js +50 -0
- package/packages/dd-trace/src/span_format.js +269 -81
- package/packages/dd-trace/src/span_processor.js +18 -13
- package/packages/dd-trace/src/span_stats.js +101 -79
- package/packages/dd-trace/src/spanleak.js +1 -2
- package/packages/dd-trace/src/standalone/index.js +0 -36
- package/packages/dd-trace/src/startup-log.js +3 -3
- package/packages/dd-trace/src/tagger.js +2 -4
- package/packages/dd-trace/src/telemetry/dependencies.js +2 -2
- package/packages/dd-trace/src/telemetry/endpoints.js +7 -5
- package/packages/dd-trace/src/telemetry/index.js +2 -2
- package/packages/dd-trace/src/telemetry/logs/index.js +1 -1
- package/packages/dd-trace/src/telemetry/send-data.js +22 -22
- package/packages/dd-trace/src/telemetry/session-propagation.js +1 -1
- package/packages/dd-trace/src/telemetry/telemetry.js +16 -14
- package/packages/dd-trace/src/tracer.js +23 -9
- package/packages/dd-trace/src/tracer_metadata.js +1 -1
- package/packages/dd-trace/src/util.js +57 -0
- package/register.js +58 -1
- package/vendor/dist/@apm-js-collab/code-transformer/index.js +94 -42
- package/vendor/dist/@datadog/sketches-js/LICENSE +10 -36
- package/vendor/dist/@datadog/sketches-js/index.js +1 -1
- package/vendor/dist/pprof-format/index.js +1 -1
- package/vendor/dist/protobufjs/index.js +1 -1
- package/vendor/dist/protobufjs/minimal/index.js +1 -1
- package/vendor/dist/shell-quote/index.js +1 -1
- package/packages/datadog-plugin-graphql/src/resolve.js +0 -178
- package/packages/dd-trace/src/agent/url.js +0 -28
- package/packages/dd-trace/src/appsec/api_security_sampler.js +0 -117
- package/packages/dd-trace/src/lambda/runtime/ritm.js +0 -133
- package/packages/dd-trace/src/log/utils.js +0 -16
- package/packages/dd-trace/src/msgpack/encoder.js +0 -308
- package/packages/dd-trace/src/plugins/structured_log_plugin.js +0 -9
- package/scripts/preinstall.js +0 -34
- package/vendor/dist/ignore/LICENSE +0 -21
- package/vendor/dist/ignore/index.js +0 -1
- package/vendor/dist/opentracing/LICENSE +0 -201
- package/vendor/dist/opentracing/binary_carrier.d.ts +0 -11
- package/vendor/dist/opentracing/constants.d.ts +0 -61
- package/vendor/dist/opentracing/examples/demo/demo.d.ts +0 -2
- package/vendor/dist/opentracing/ext/tags.d.ts +0 -90
- package/vendor/dist/opentracing/functions.d.ts +0 -20
- package/vendor/dist/opentracing/global_tracer.d.ts +0 -14
- package/vendor/dist/opentracing/index.d.ts +0 -12
- package/vendor/dist/opentracing/index.js +0 -1
- package/vendor/dist/opentracing/mock_tracer/index.d.ts +0 -5
- package/vendor/dist/opentracing/mock_tracer/mock_context.d.ts +0 -13
- package/vendor/dist/opentracing/mock_tracer/mock_report.d.ts +0 -16
- package/vendor/dist/opentracing/mock_tracer/mock_span.d.ts +0 -50
- package/vendor/dist/opentracing/mock_tracer/mock_tracer.d.ts +0 -26
- package/vendor/dist/opentracing/noop.d.ts +0 -8
- package/vendor/dist/opentracing/reference.d.ts +0 -33
- package/vendor/dist/opentracing/span.d.ts +0 -147
- package/vendor/dist/opentracing/span_context.d.ts +0 -26
- package/vendor/dist/opentracing/test/api_compatibility.d.ts +0 -16
- package/vendor/dist/opentracing/test/mocktracer_implemenation.d.ts +0 -3
- package/vendor/dist/opentracing/test/noop_implementation.d.ts +0 -4
- package/vendor/dist/opentracing/test/opentracing_api.d.ts +0 -3
- package/vendor/dist/opentracing/test/unittest.d.ts +0 -2
- package/vendor/dist/opentracing/tracer.d.ts +0 -127
- package/vendor/dist/path-to-regexp/LICENSE +0 -21
- package/vendor/dist/path-to-regexp/index.js +0 -1
|
@@ -0,0 +1,862 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const path = require('path')
|
|
4
|
+
|
|
5
|
+
const { getArtifactId } = require('./artifact-id')
|
|
6
|
+
const {
|
|
7
|
+
MAX_GENERATED_FILES,
|
|
8
|
+
getGeneratedFileContentError,
|
|
9
|
+
} = require('./generated-file-policy')
|
|
10
|
+
const { getInlineDatadogInitialization } = require('./local-command')
|
|
11
|
+
const {
|
|
12
|
+
hasUnsafeExecutionCharacter,
|
|
13
|
+
hasUnsafeInvisibleCharacter,
|
|
14
|
+
isSensitiveName,
|
|
15
|
+
sanitizeForReport,
|
|
16
|
+
sanitizeString,
|
|
17
|
+
} = require('./redaction')
|
|
18
|
+
|
|
19
|
+
const FRAMEWORKS = new Set([
|
|
20
|
+
'jest',
|
|
21
|
+
'vitest',
|
|
22
|
+
'mocha',
|
|
23
|
+
'cucumber',
|
|
24
|
+
'cypress',
|
|
25
|
+
'playwright',
|
|
26
|
+
'node:test',
|
|
27
|
+
'ava',
|
|
28
|
+
'tap',
|
|
29
|
+
'jasmine',
|
|
30
|
+
'karma',
|
|
31
|
+
'uvu',
|
|
32
|
+
'testcafe',
|
|
33
|
+
'custom',
|
|
34
|
+
'unknown',
|
|
35
|
+
])
|
|
36
|
+
|
|
37
|
+
const STATUSES = new Set([
|
|
38
|
+
'runnable',
|
|
39
|
+
'detected_not_runnable',
|
|
40
|
+
'requires_external_service',
|
|
41
|
+
'requires_manual_setup',
|
|
42
|
+
'unsupported_by_validator',
|
|
43
|
+
'unknown',
|
|
44
|
+
])
|
|
45
|
+
const CI_WIRING_STATUSES = new Set([
|
|
46
|
+
'pass',
|
|
47
|
+
'fail',
|
|
48
|
+
'skip',
|
|
49
|
+
'unknown',
|
|
50
|
+
])
|
|
51
|
+
const CI_WIRING_REPLAYABILITIES = new Set(['replayable', 'not_replayable'])
|
|
52
|
+
const CI_INITIALIZATION_STATUSES = new Set(['configured', 'not_configured', 'unknown'])
|
|
53
|
+
const UNRESOLVED_PLACEHOLDER_PATTERN = /\$\{[^}]+\}/
|
|
54
|
+
const ENV_NAME_PATTERN = /^[A-Za-z_][A-Za-z0-9_]*$/
|
|
55
|
+
const MAX_COMMAND_TIMEOUT_MS = 30 * 60 * 1000
|
|
56
|
+
const MAX_FRAMEWORKS = 100
|
|
57
|
+
const MAX_MANIFEST_ARRAY_ENTRIES = 1000
|
|
58
|
+
const MAX_SETUP_COMMANDS = 100
|
|
59
|
+
const MAX_VALIDATION_ERRORS = 50
|
|
60
|
+
const MAX_REPRESENTATIVE_TESTS = 1000
|
|
61
|
+
const SECRET_PLACEHOLDER = 'dd-validation-placeholder'
|
|
62
|
+
const SAFE_SECRET_FIELD_VALUES = new Set(['', '0', '1', 'false', 'true', 'none', 'disabled'])
|
|
63
|
+
const COMMAND_FIELDS = new Set([
|
|
64
|
+
'argv',
|
|
65
|
+
'cwd',
|
|
66
|
+
'description',
|
|
67
|
+
'env',
|
|
68
|
+
'required',
|
|
69
|
+
'requiredEnvVars',
|
|
70
|
+
'shell',
|
|
71
|
+
'shellCommand',
|
|
72
|
+
'shellReason',
|
|
73
|
+
'timeoutMs',
|
|
74
|
+
'usesShell',
|
|
75
|
+
'id',
|
|
76
|
+
'outputPaths',
|
|
77
|
+
])
|
|
78
|
+
|
|
79
|
+
const GENERATED_SCENARIO_IDS = new Set([
|
|
80
|
+
'basic-pass',
|
|
81
|
+
'atr-fail-once',
|
|
82
|
+
'test-management-target',
|
|
83
|
+
])
|
|
84
|
+
const GENERATED_SCENARIO_EXIT_CODES = {
|
|
85
|
+
'basic-pass': 0,
|
|
86
|
+
'atr-fail-once': 1,
|
|
87
|
+
'test-management-target': 0,
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function validateManifest (manifest) {
|
|
91
|
+
const errors = createErrorCollector()
|
|
92
|
+
|
|
93
|
+
if (!manifest || typeof manifest !== 'object') {
|
|
94
|
+
return ['Manifest must be a JSON object.']
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
requiredString(manifest, 'schemaVersion', errors)
|
|
98
|
+
requiredObject(manifest, 'repository', errors)
|
|
99
|
+
requiredObject(manifest, 'environment', errors)
|
|
100
|
+
requiredArray(manifest, 'frameworks', errors)
|
|
101
|
+
if (Array.isArray(manifest.frameworks) && manifest.frameworks.length === 0) {
|
|
102
|
+
errors.push('frameworks must include at least one framework entry.')
|
|
103
|
+
}
|
|
104
|
+
validateArrayLimit(manifest, 'frameworks', MAX_FRAMEWORKS, errors)
|
|
105
|
+
validateArrayLimit(manifest, 'omitted', MAX_MANIFEST_ARRAY_ENTRIES, errors)
|
|
106
|
+
validateArrayLimit(manifest, 'omittedTestCommands', MAX_MANIFEST_ARRAY_ENTRIES, errors)
|
|
107
|
+
|
|
108
|
+
if (manifest.repository) {
|
|
109
|
+
requiredAbsolutePath(manifest.repository, 'root', errors)
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (manifest.ciDiscovery) {
|
|
113
|
+
validateCiDiscovery(manifest.ciDiscovery, 'ciDiscovery', errors)
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (Array.isArray(manifest.frameworks)) {
|
|
117
|
+
const frameworks = manifest.frameworks.slice(0, MAX_FRAMEWORKS)
|
|
118
|
+
validateUniqueFrameworkIds(frameworks, errors)
|
|
119
|
+
validateUniqueArtifactIds(frameworks, errors)
|
|
120
|
+
validateDuplicateRunnableCoverage(frameworks, errors)
|
|
121
|
+
validateGeneratedPathCollisions(frameworks, errors)
|
|
122
|
+
for (const [index, framework] of frameworks.entries()) {
|
|
123
|
+
validateFramework(framework, index, errors)
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
validateRepositoryContainedPaths(manifest, errors)
|
|
128
|
+
|
|
129
|
+
return errors.finalize()
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Rejects generated files or cleanup targets shared by multiple framework entries.
|
|
134
|
+
*
|
|
135
|
+
* @param {object[]} frameworks manifest framework entries
|
|
136
|
+
* @param {{push: function(string): void}} errors bounded validation error collector
|
|
137
|
+
* @returns {void}
|
|
138
|
+
*/
|
|
139
|
+
function validateGeneratedPathCollisions (frameworks, errors) {
|
|
140
|
+
const seen = new Map()
|
|
141
|
+
for (const [index, framework] of frameworks.entries()) {
|
|
142
|
+
const strategy = framework?.generatedTestStrategy
|
|
143
|
+
const frameworkPaths = new Map([
|
|
144
|
+
...limitedArray(strategy?.files, MAX_GENERATED_FILES).map(file => file?.path),
|
|
145
|
+
...limitedArray(strategy?.cleanupPaths, MAX_MANIFEST_ARRAY_ENTRIES),
|
|
146
|
+
].filter(filename => typeof filename === 'string' && path.isAbsolute(filename))
|
|
147
|
+
.map(filename => [path.normalize(filename), filename]))
|
|
148
|
+
|
|
149
|
+
for (const [key, filename] of frameworkPaths) {
|
|
150
|
+
const previous = seen.get(key)
|
|
151
|
+
if (previous === undefined) {
|
|
152
|
+
seen.set(key, index)
|
|
153
|
+
continue
|
|
154
|
+
}
|
|
155
|
+
errors.push(
|
|
156
|
+
`frameworks[${index}].generatedTestStrategy path ${JSON.stringify(filename)} conflicts with ` +
|
|
157
|
+
`frameworks[${previous}].generatedTestStrategy. Generated files and cleanup paths must be unique across ` +
|
|
158
|
+
'framework entries.'
|
|
159
|
+
)
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
function validateDuplicateRunnableCoverage (frameworks, errors) {
|
|
165
|
+
const seen = new Map()
|
|
166
|
+
for (const [index, framework] of frameworks.entries()) {
|
|
167
|
+
if (framework?.status !== 'runnable' || !framework.ciWiringCommand) continue
|
|
168
|
+
const key = JSON.stringify({
|
|
169
|
+
framework: framework.framework,
|
|
170
|
+
projectRoot: framework.project?.root,
|
|
171
|
+
existingTestCommand: commandExecutionShape(framework.existingTestCommand),
|
|
172
|
+
ciWiringCommand: commandExecutionShape(framework.ciWiringCommand),
|
|
173
|
+
ciInitializesDatadog: commandInitializesDatadog(framework.ciWiringCommand),
|
|
174
|
+
})
|
|
175
|
+
const previous = seen.get(key)
|
|
176
|
+
if (previous === undefined) {
|
|
177
|
+
seen.set(key, index)
|
|
178
|
+
continue
|
|
179
|
+
}
|
|
180
|
+
errors.push(
|
|
181
|
+
`frameworks[${index}] duplicates runnable framework and CI command coverage from frameworks[${previous}]. ` +
|
|
182
|
+
'Keep one representative framework entry and record the other CI job as an omitted or duplicate candidate.'
|
|
183
|
+
)
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function validateUniqueArtifactIds (frameworks, errors) {
|
|
188
|
+
const seen = new Map()
|
|
189
|
+
for (const [index, framework] of frameworks.entries()) {
|
|
190
|
+
if (typeof framework?.id !== 'string') continue
|
|
191
|
+
const artifactId = getArtifactId(framework.id)
|
|
192
|
+
const previous = seen.get(artifactId)
|
|
193
|
+
if (previous !== undefined && previous !== framework.id) {
|
|
194
|
+
errors.push(
|
|
195
|
+
`frameworks[${index}].id collides with another framework artifact identifier after normalization.`
|
|
196
|
+
)
|
|
197
|
+
} else {
|
|
198
|
+
seen.set(artifactId, framework.id)
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
function commandExecutionShape (command) {
|
|
204
|
+
if (!command) return null
|
|
205
|
+
return {
|
|
206
|
+
argv: command.argv,
|
|
207
|
+
cwd: command.cwd,
|
|
208
|
+
shell: command.shell,
|
|
209
|
+
shellCommand: command.shellCommand,
|
|
210
|
+
usesShell: Boolean(command.usesShell),
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
function commandInitializesDatadog (command) {
|
|
215
|
+
const values = [
|
|
216
|
+
...(command?.argv || []),
|
|
217
|
+
command?.shellCommand,
|
|
218
|
+
command?.env?.NODE_OPTIONS,
|
|
219
|
+
].filter(Boolean).join(' ')
|
|
220
|
+
return /dd-trace\/ci\/init/.test(values)
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
function validateRepositoryContainedPaths (manifest, errors) {
|
|
224
|
+
const repositoryRoot = manifest.repository?.root
|
|
225
|
+
if (typeof repositoryRoot !== 'string' || !path.isAbsolute(repositoryRoot)) return
|
|
226
|
+
|
|
227
|
+
const frameworks = Array.isArray(manifest.frameworks) ? manifest.frameworks.slice(0, MAX_FRAMEWORKS) : []
|
|
228
|
+
for (const [index, framework] of frameworks.entries()) {
|
|
229
|
+
if (!framework || typeof framework !== 'object' || Array.isArray(framework)) continue
|
|
230
|
+
const prefix = `frameworks[${index}]`
|
|
231
|
+
containedPath(repositoryRoot, framework.project?.root, `${prefix}.project.root`, errors)
|
|
232
|
+
containedPath(repositoryRoot, framework.project?.packageJson, `${prefix}.project.packageJson`, errors)
|
|
233
|
+
for (const [configIndex, configFile] of
|
|
234
|
+
limitedArray(framework.project?.configFiles, MAX_MANIFEST_ARRAY_ENTRIES).entries()) {
|
|
235
|
+
containedPath(repositoryRoot, configFile, `${prefix}.project.configFiles[${configIndex}]`, errors)
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
for (const [name, command] of getFrameworkCommands(framework)) {
|
|
239
|
+
containedPath(repositoryRoot, command?.cwd, `${prefix}.${name}.cwd`, errors)
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
containedPath(repositoryRoot, framework.ciWiring?.configFile, `${prefix}.ciWiring.configFile`, errors)
|
|
243
|
+
containedPath(repositoryRoot, framework.ciWiring?.workingDirectory, `${prefix}.ciWiring.workingDirectory`, errors)
|
|
244
|
+
|
|
245
|
+
const strategy = framework.generatedTestStrategy
|
|
246
|
+
containedPath(repositoryRoot, strategy?.testDirectory, `${prefix}.generatedTestStrategy.testDirectory`, errors)
|
|
247
|
+
for (const [fileIndex, file] of limitedArray(strategy?.files, MAX_GENERATED_FILES).entries()) {
|
|
248
|
+
containedPath(repositoryRoot, file?.path, `${prefix}.generatedTestStrategy.files[${fileIndex}].path`, errors)
|
|
249
|
+
}
|
|
250
|
+
for (const [cleanupIndex, cleanupPath] of
|
|
251
|
+
limitedArray(strategy?.cleanupPaths, MAX_MANIFEST_ARRAY_ENTRIES).entries()) {
|
|
252
|
+
containedPath(
|
|
253
|
+
repositoryRoot,
|
|
254
|
+
cleanupPath,
|
|
255
|
+
`${prefix}.generatedTestStrategy.cleanupPaths[${cleanupIndex}]`,
|
|
256
|
+
errors
|
|
257
|
+
)
|
|
258
|
+
}
|
|
259
|
+
for (const [scenarioIndex, scenario] of
|
|
260
|
+
limitedArray(strategy?.scenarios, GENERATED_SCENARIO_IDS.size).entries()) {
|
|
261
|
+
for (const [identityIndex, identity] of
|
|
262
|
+
limitedArray(scenario?.testIdentities, MAX_MANIFEST_ARRAY_ENTRIES).entries()) {
|
|
263
|
+
containedPath(
|
|
264
|
+
repositoryRoot,
|
|
265
|
+
identity?.file,
|
|
266
|
+
`${prefix}.generatedTestStrategy.scenarios[${scenarioIndex}].testIdentities[${identityIndex}].file`,
|
|
267
|
+
errors
|
|
268
|
+
)
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
function getFrameworkCommands (framework) {
|
|
275
|
+
const commands = []
|
|
276
|
+
for (const name of ['existingTestCommand', 'ciWiringCommand']) {
|
|
277
|
+
if (framework[name]) commands.push([name, framework[name]])
|
|
278
|
+
}
|
|
279
|
+
for (const [index, command] of limitedArray(framework.setup?.commands, MAX_SETUP_COMMANDS).entries()) {
|
|
280
|
+
commands.push([`setup.commands[${index}]`, command])
|
|
281
|
+
}
|
|
282
|
+
for (const [index, scenario] of
|
|
283
|
+
limitedArray(framework.generatedTestStrategy?.scenarios, GENERATED_SCENARIO_IDS.size).entries()) {
|
|
284
|
+
if (scenario?.runCommand) {
|
|
285
|
+
commands.push([`generatedTestStrategy.scenarios[${index}].runCommand`, scenario.runCommand])
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
return commands
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
function containedPath (root, candidate, key, errors) {
|
|
292
|
+
if (typeof candidate !== 'string' || !path.isAbsolute(candidate)) return
|
|
293
|
+
const relative = path.relative(path.resolve(root), path.resolve(candidate))
|
|
294
|
+
if (relative === '' || (relative && !relative.startsWith('..') && !path.isAbsolute(relative))) return
|
|
295
|
+
errors.push(`${key} must be inside repository.root.`)
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
function validateCiDiscovery (ciDiscovery, prefix, errors) {
|
|
299
|
+
if (!ciDiscovery || typeof ciDiscovery !== 'object' || Array.isArray(ciDiscovery)) {
|
|
300
|
+
errors.push(`${prefix} must be an object when present.`)
|
|
301
|
+
return
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
for (const field of ['searched', 'found', 'staticFound', 'warnings', 'notes', 'contradictions']) {
|
|
305
|
+
if (ciDiscovery[field] !== undefined) {
|
|
306
|
+
if (Array.isArray(ciDiscovery[field])) {
|
|
307
|
+
validateStringArray(ciDiscovery, field, errors, prefix)
|
|
308
|
+
} else {
|
|
309
|
+
errors.push(`${prefix}.${field} must be an array when present.`)
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
if (ciDiscovery.method !== undefined && typeof ciDiscovery.method !== 'string') {
|
|
315
|
+
errors.push(`${prefix}.method must be a string when present.`)
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
function validateFramework (framework, index, errors) {
|
|
320
|
+
const prefix = `frameworks[${index}]`
|
|
321
|
+
if (!framework || typeof framework !== 'object' || Array.isArray(framework)) {
|
|
322
|
+
errors.push(`${prefix} must be an object.`)
|
|
323
|
+
return
|
|
324
|
+
}
|
|
325
|
+
requiredString(framework, 'id', errors, prefix)
|
|
326
|
+
enumString(framework, 'framework', FRAMEWORKS, errors, prefix)
|
|
327
|
+
enumString(framework, 'status', STATUSES, errors, prefix)
|
|
328
|
+
requiredObject(framework, 'project', errors, prefix)
|
|
329
|
+
|
|
330
|
+
if (framework.project) {
|
|
331
|
+
requiredAbsolutePath(framework.project, 'root', errors, `${prefix}.project`)
|
|
332
|
+
optionalAbsolutePath(framework.project, 'packageJson', errors, `${prefix}.project`)
|
|
333
|
+
optionalAbsolutePathArray(framework.project, 'configFiles', errors, `${prefix}.project`)
|
|
334
|
+
validateArrayLimit(framework.project, 'configFiles', MAX_MANIFEST_ARRAY_ENTRIES, errors, `${prefix}.project`)
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
if (framework.status === 'runnable') {
|
|
338
|
+
requiredCommand(framework, 'existingTestCommand', errors, prefix, { datadogClean: true })
|
|
339
|
+
validateDatadogCleanCommand(framework.existingTestCommand, `${prefix}.existingTestCommand`, errors)
|
|
340
|
+
requiredObject(framework, 'preflight', errors, prefix)
|
|
341
|
+
validatePreflight(framework.preflight, `${prefix}.preflight`, errors)
|
|
342
|
+
requiredObject(framework, 'ciWiring', errors, prefix)
|
|
343
|
+
} else {
|
|
344
|
+
requireNonEmptyNotes(framework, errors, prefix)
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
if (framework.ciWiringCommand) {
|
|
348
|
+
requiredCommand(framework, 'ciWiringCommand', errors, prefix)
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
if (framework.ciWiring) {
|
|
352
|
+
validateCiWiring(framework, prefix, errors)
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
if (framework.forcedLocalCommand !== undefined) {
|
|
356
|
+
errors.push(
|
|
357
|
+
`${prefix}.forcedLocalCommand is not supported. Use the focused existingTestCommand for Basic Reporting ` +
|
|
358
|
+
'and ciWiringCommand for the CI-shaped replay.'
|
|
359
|
+
)
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
if (framework.setup?.commands) {
|
|
363
|
+
if (Array.isArray(framework.setup.commands)) {
|
|
364
|
+
validateArrayLimit(framework.setup, 'commands', MAX_SETUP_COMMANDS, errors, `${prefix}.setup`)
|
|
365
|
+
for (const [commandIndex, command] of framework.setup.commands.slice(0, MAX_SETUP_COMMANDS).entries()) {
|
|
366
|
+
requiredCommand({ command }, 'command', errors, `${prefix}.setup.commands[${commandIndex}]`)
|
|
367
|
+
}
|
|
368
|
+
} else {
|
|
369
|
+
errors.push(`${prefix}.setup.commands must be an array.`)
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
if (framework.generatedTestStrategy) {
|
|
374
|
+
validateGeneratedTestStrategy(framework.generatedTestStrategy, `${prefix}.generatedTestStrategy`, errors)
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* Validates the approved upper bound for a representative test command.
|
|
380
|
+
*
|
|
381
|
+
* @param {object} preflight preflight declaration
|
|
382
|
+
* @param {string} prefix manifest field path
|
|
383
|
+
* @param {{push: function(string): void}} errors bounded validation error collector
|
|
384
|
+
* @returns {void}
|
|
385
|
+
*/
|
|
386
|
+
function validatePreflight (preflight, prefix, errors) {
|
|
387
|
+
if (!preflight || typeof preflight !== 'object' || Array.isArray(preflight)) return
|
|
388
|
+
|
|
389
|
+
if (!Number.isInteger(preflight.maxTestCount) || preflight.maxTestCount < 1) {
|
|
390
|
+
errors.push(`${prefix}.maxTestCount must be a positive integer.`)
|
|
391
|
+
} else if (preflight.maxTestCount > MAX_REPRESENTATIVE_TESTS) {
|
|
392
|
+
errors.push(`${prefix}.maxTestCount must not exceed ${MAX_REPRESENTATIVE_TESTS}.`)
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
function validateGeneratedTestStrategy (strategy, prefix, errors) {
|
|
397
|
+
if (!['planned', 'verified', 'proposed', 'not_possible'].includes(strategy.status)) {
|
|
398
|
+
errors.push(`${prefix}.status must be planned, verified, proposed, or not_possible.`)
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
const completeStrategy = strategy.status === 'planned' || strategy.status === 'verified'
|
|
402
|
+
if (completeStrategy) {
|
|
403
|
+
requiredArray(strategy, 'files', errors, prefix)
|
|
404
|
+
requiredArray(strategy, 'scenarios', errors, prefix)
|
|
405
|
+
requiredArray(strategy, 'cleanupPaths', errors, prefix)
|
|
406
|
+
validateCompleteGeneratedScenarioSet(strategy, prefix, errors)
|
|
407
|
+
} else if ((strategy.status === 'proposed' || strategy.status === 'not_possible') &&
|
|
408
|
+
(typeof strategy.reason !== 'string' || strategy.reason.trim() === '')) {
|
|
409
|
+
errors.push(`${prefix}.reason must explain why the generated test strategy is ${strategy.status}.`)
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
if (Array.isArray(strategy.files)) {
|
|
413
|
+
if (strategy.files.length > MAX_GENERATED_FILES) {
|
|
414
|
+
errors.push(`${prefix}.files must contain at most ${MAX_GENERATED_FILES} generated files.`)
|
|
415
|
+
}
|
|
416
|
+
for (const [index, file] of strategy.files.slice(0, MAX_GENERATED_FILES).entries()) {
|
|
417
|
+
requiredAbsolutePath(file, 'path', errors, `${prefix}.files[${index}]`)
|
|
418
|
+
requiredArray(file, 'contentLines', errors, `${prefix}.files[${index}]`)
|
|
419
|
+
validateStringArray(file, 'contentLines', errors, `${prefix}.files[${index}]`)
|
|
420
|
+
const policyError = getGeneratedFileContentError(file.contentLines)
|
|
421
|
+
if (policyError) errors.push(`${prefix}.files[${index}].contentLines ${policyError}.`)
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
if (Array.isArray(strategy.scenarios)) {
|
|
426
|
+
validateArrayLimit(strategy, 'scenarios', GENERATED_SCENARIO_IDS.size, errors, prefix)
|
|
427
|
+
for (const [index, scenario] of strategy.scenarios.slice(0, GENERATED_SCENARIO_IDS.size).entries()) {
|
|
428
|
+
requiredString(scenario, 'id', errors, `${prefix}.scenarios[${index}]`)
|
|
429
|
+
enumString(scenario, 'id', GENERATED_SCENARIO_IDS, errors, `${prefix}.scenarios[${index}]`)
|
|
430
|
+
requiredCommand(scenario, 'runCommand', errors, `${prefix}.scenarios[${index}]`, { datadogClean: true })
|
|
431
|
+
validateDatadogCleanCommand(scenario.runCommand, `${prefix}.scenarios[${index}].runCommand`, errors)
|
|
432
|
+
validateScenarioIdentities(
|
|
433
|
+
scenario,
|
|
434
|
+
`${prefix}.scenarios[${index}]`,
|
|
435
|
+
errors,
|
|
436
|
+
completeStrategy
|
|
437
|
+
)
|
|
438
|
+
if (completeStrategy) {
|
|
439
|
+
validateGeneratedScenarioOutcome(scenario, `${prefix}.scenarios[${index}]`, errors)
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
optionalAbsolutePath(strategy, 'testDirectory', errors, prefix)
|
|
445
|
+
optionalAbsolutePathArray(strategy, 'cleanupPaths', errors, prefix)
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
function validateCiWiring (framework, prefix, errors) {
|
|
449
|
+
const ciWiring = framework.ciWiring
|
|
450
|
+
if (!ciWiring || typeof ciWiring !== 'object' || Array.isArray(ciWiring)) {
|
|
451
|
+
errors.push(`${prefix}.ciWiring must be an object when present.`)
|
|
452
|
+
return
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
if (!CI_WIRING_STATUSES.has(ciWiring.status)) {
|
|
456
|
+
errors.push(`${prefix}.ciWiring.status must be pass, fail, skip, or unknown.`)
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
if (!CI_WIRING_REPLAYABILITIES.has(ciWiring.replayability)) {
|
|
460
|
+
errors.push(`${prefix}.ciWiring.replayability must be replayable or not_replayable.`)
|
|
461
|
+
}
|
|
462
|
+
if (Object.hasOwn(ciWiring, 'ciWiringCommand')) {
|
|
463
|
+
errors.push(`${prefix}.ciWiring.ciWiringCommand is misplaced; use ${prefix}.ciWiringCommand.`)
|
|
464
|
+
}
|
|
465
|
+
if (ciWiring.replayability === 'replayable' && !framework.ciWiringCommand) {
|
|
466
|
+
errors.push(`${prefix}.ciWiringCommand is required when ${prefix}.ciWiring.replayability is replayable.`)
|
|
467
|
+
}
|
|
468
|
+
if (ciWiring.replayability === 'not_replayable') {
|
|
469
|
+
if (ciWiring.status === 'pass' || ciWiring.status === 'fail') {
|
|
470
|
+
errors.push(`${prefix}.ciWiring.status must be skip or unknown when replayability is not_replayable.`)
|
|
471
|
+
}
|
|
472
|
+
if (framework.ciWiringCommand) {
|
|
473
|
+
errors.push(`${prefix}.ciWiringCommand must be omitted when ${prefix}.ciWiring.replayability is not_replayable.`)
|
|
474
|
+
}
|
|
475
|
+
if (!hasNonEmptyString(ciWiring.replayBlocker)) {
|
|
476
|
+
errors.push(`${prefix}.ciWiring.replayBlocker must explain why CI replay is not_replayable.`)
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
if (ciWiring.initialization !== undefined) {
|
|
481
|
+
validateCiInitialization(ciWiring.initialization, `${prefix}.ciWiring.initialization`, errors)
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
if (ciWiring.initialization?.status === 'not_configured' &&
|
|
485
|
+
commandInitializesDatadog(framework.ciWiringCommand)) {
|
|
486
|
+
errors.push(
|
|
487
|
+
`${prefix}.ciWiring.initialization.status is not_configured, but ${prefix}.ciWiringCommand adds dd-trace ` +
|
|
488
|
+
'initialization. The replay command must preserve the discovered CI configuration; remove the added ' +
|
|
489
|
+
'initialization or correct the initialization status and evidence.'
|
|
490
|
+
)
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
if (framework.ciWiringCommand) {
|
|
494
|
+
for (const field of ['provider', 'configFile', 'job', 'step', 'whySelected']) {
|
|
495
|
+
requiredString(ciWiring, field, errors, `${prefix}.ciWiring`)
|
|
496
|
+
}
|
|
497
|
+
requiredAbsolutePath(ciWiring, 'configFile', errors, `${prefix}.ciWiring`)
|
|
498
|
+
requiredAbsolutePath(ciWiring, 'workingDirectory', errors, `${prefix}.ciWiring`)
|
|
499
|
+
if (path.resolve(ciWiring.workingDirectory || '') !== path.resolve(framework.ciWiringCommand.cwd || '')) {
|
|
500
|
+
errors.push(`${prefix}.ciWiringCommand.cwd must match ${prefix}.ciWiring.workingDirectory.`)
|
|
501
|
+
}
|
|
502
|
+
if (ciWiring.shell !== undefined && ciWiring.shell !== null) {
|
|
503
|
+
if (typeof ciWiring.shell !== 'string' || ciWiring.shell.trim() === '') {
|
|
504
|
+
errors.push(`${prefix}.ciWiring.shell must be a non-empty string when present.`)
|
|
505
|
+
} else if (hasUnsafeExecutionCharacter(ciWiring.shell)) {
|
|
506
|
+
errors.push(`${prefix}.ciWiring.shell must not contain invisible or control characters.`)
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
if ((ciWiring.status === 'skip' || ciWiring.status === 'unknown') &&
|
|
512
|
+
!hasNonEmptyString(ciWiring.diagnosis) && !hasNonEmptyString(ciWiring.reason)) {
|
|
513
|
+
errors.push(`${prefix}.ciWiring must explain why CI wiring is ${ciWiring.status}.`)
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
function validateCiInitialization (initialization, prefix, errors) {
|
|
518
|
+
if (!initialization || typeof initialization !== 'object' || Array.isArray(initialization)) {
|
|
519
|
+
errors.push(`${prefix} must be an object when present.`)
|
|
520
|
+
return
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
if (!CI_INITIALIZATION_STATUSES.has(initialization.status)) {
|
|
524
|
+
errors.push(`${prefix}.status must be configured, not_configured, or unknown.`)
|
|
525
|
+
}
|
|
526
|
+
if (Array.isArray(initialization.evidence)) {
|
|
527
|
+
validateStringArray(initialization, 'evidence', errors, prefix)
|
|
528
|
+
if (initialization.status !== 'unknown' && initialization.evidence.length === 0) {
|
|
529
|
+
errors.push(`${prefix}.evidence must explain the ${initialization.status} conclusion.`)
|
|
530
|
+
}
|
|
531
|
+
} else {
|
|
532
|
+
errors.push(`${prefix}.evidence must be an array.`)
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
function hasNonEmptyString (value) {
|
|
537
|
+
return typeof value === 'string' && value.trim() !== ''
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
function validateDatadogCleanCommand (command, prefix, errors) {
|
|
541
|
+
for (const [name, value] of Object.entries(command?.env || {})) {
|
|
542
|
+
if (name.startsWith('DD_') || (name === 'NODE_OPTIONS' && /dd-trace/.test(String(value)))) {
|
|
543
|
+
errors.push(`${prefix}.env.${name} must not configure Datadog initialization for local validation.`)
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
const inlineInitialization = getInlineDatadogInitialization(command)
|
|
548
|
+
if (inlineInitialization) {
|
|
549
|
+
errors.push(
|
|
550
|
+
`${prefix} ${inlineInitialization} and must be Datadog-clean for local validation. ` +
|
|
551
|
+
'Remove the inline initialization; preserve exact CI initialization only in ciWiringCommand.'
|
|
552
|
+
)
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
function validateGeneratedScenarioOutcome (scenario, prefix, errors) {
|
|
557
|
+
const expected = scenario.expectedWithoutDatadog
|
|
558
|
+
if (!expected || typeof expected !== 'object' || Array.isArray(expected)) {
|
|
559
|
+
errors.push(`${prefix}.expectedWithoutDatadog must be an object when generatedTestStrategy is planned or verified.`)
|
|
560
|
+
return
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
const expectedExitCode = GENERATED_SCENARIO_EXIT_CODES[scenario.id]
|
|
564
|
+
if (expectedExitCode !== undefined && expected.exitCode !== expectedExitCode) {
|
|
565
|
+
errors.push(`${prefix}.expectedWithoutDatadog.exitCode must be ${expectedExitCode} for ${scenario.id}.`)
|
|
566
|
+
}
|
|
567
|
+
if (expected.observedTestCount !== 1) {
|
|
568
|
+
errors.push(`${prefix}.expectedWithoutDatadog.observedTestCount must be 1 so the command isolates this scenario.`)
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
function validateCompleteGeneratedScenarioSet (strategy, prefix, errors) {
|
|
573
|
+
if (!Array.isArray(strategy.scenarios)) return
|
|
574
|
+
|
|
575
|
+
const seen = new Set()
|
|
576
|
+
for (const scenario of strategy.scenarios.slice(0, GENERATED_SCENARIO_IDS.size)) {
|
|
577
|
+
if (typeof scenario?.id === 'string') seen.add(scenario.id)
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
for (const scenarioId of GENERATED_SCENARIO_IDS) {
|
|
581
|
+
if (!seen.has(scenarioId)) {
|
|
582
|
+
errors.push(`${prefix}.scenarios must include generated scenario "${scenarioId}" when status is planned or ` +
|
|
583
|
+
'verified.')
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
function validateUniqueFrameworkIds (frameworks, errors) {
|
|
589
|
+
const seen = new Set()
|
|
590
|
+
for (const [index, framework] of frameworks.entries()) {
|
|
591
|
+
if (typeof framework?.id !== 'string') continue
|
|
592
|
+
if (seen.has(framework.id)) {
|
|
593
|
+
errors.push(`frameworks[${index}].id must be unique; duplicate "${framework.id}".`)
|
|
594
|
+
}
|
|
595
|
+
seen.add(framework.id)
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
function requireNonEmptyNotes (framework, errors, prefix) {
|
|
600
|
+
if (!Array.isArray(framework.notes) || framework.notes.length === 0) {
|
|
601
|
+
errors.push(`${prefix}.notes must include a reason when status is ${framework.status}.`)
|
|
602
|
+
return
|
|
603
|
+
}
|
|
604
|
+
validateStringArray(framework, 'notes', errors, prefix)
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
function validateScenarioIdentities (scenario, prefix, errors, required = false) {
|
|
608
|
+
if (!Array.isArray(scenario.testIdentities)) {
|
|
609
|
+
if (required) {
|
|
610
|
+
errors.push(`${prefix}.testIdentities must be a non-empty array when generatedTestStrategy is planned or ` +
|
|
611
|
+
'verified.')
|
|
612
|
+
}
|
|
613
|
+
return
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
if (required && scenario.testIdentities.length === 0) {
|
|
617
|
+
errors.push(`${prefix}.testIdentities must be a non-empty array when generatedTestStrategy is planned or verified.`)
|
|
618
|
+
}
|
|
619
|
+
validateArrayLimit(
|
|
620
|
+
{ testIdentities: scenario.testIdentities },
|
|
621
|
+
'testIdentities',
|
|
622
|
+
MAX_MANIFEST_ARRAY_ENTRIES,
|
|
623
|
+
errors,
|
|
624
|
+
prefix
|
|
625
|
+
)
|
|
626
|
+
|
|
627
|
+
for (const [index, identity] of scenario.testIdentities.slice(0, MAX_MANIFEST_ARRAY_ENTRIES).entries()) {
|
|
628
|
+
const identityPrefix = `${prefix}.testIdentities[${index}]`
|
|
629
|
+
if (!identity || typeof identity !== 'object' || Array.isArray(identity)) {
|
|
630
|
+
errors.push(`${identityPrefix} must be an object.`)
|
|
631
|
+
continue
|
|
632
|
+
}
|
|
633
|
+
requiredString(identity, 'name', errors, identityPrefix)
|
|
634
|
+
if (identity.suite !== undefined && identity.suite !== null && typeof identity.suite !== 'string') {
|
|
635
|
+
errors.push(`${identityPrefix}.suite must be a string or null when present.`)
|
|
636
|
+
}
|
|
637
|
+
optionalAbsolutePath(identity, 'file', errors, identityPrefix)
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
function requiredCommand (target, field, errors, prefix = '', options = {}) {
|
|
642
|
+
const value = target && target[field]
|
|
643
|
+
const key = join(prefix, field)
|
|
644
|
+
if (!value || typeof value !== 'object') {
|
|
645
|
+
errors.push(`${key} must be an object.`)
|
|
646
|
+
return
|
|
647
|
+
}
|
|
648
|
+
for (const name of Object.keys(value)) {
|
|
649
|
+
if (!COMMAND_FIELDS.has(name)) errors.push(`${key}.${name} is not an allowed command field.`)
|
|
650
|
+
}
|
|
651
|
+
if (value.usesShell !== undefined && typeof value.usesShell !== 'boolean') {
|
|
652
|
+
errors.push(`${key}.usesShell must be a boolean when present.`)
|
|
653
|
+
}
|
|
654
|
+
if (value.required !== undefined && typeof value.required !== 'boolean') {
|
|
655
|
+
errors.push(`${key}.required must be a boolean when present.`)
|
|
656
|
+
}
|
|
657
|
+
requiredAbsolutePath(value, 'cwd', errors, key)
|
|
658
|
+
rejectUnresolvedPlaceholder(value.cwd, `${key}.cwd`, errors)
|
|
659
|
+
if (value.shell !== undefined) {
|
|
660
|
+
requiredString(value, 'shell', errors, key)
|
|
661
|
+
rejectUnresolvedPlaceholder(value.shell, `${key}.shell`, errors)
|
|
662
|
+
if (!value.usesShell) errors.push(`${key}.shell requires usesShell to be true.`)
|
|
663
|
+
if (typeof value.shell === 'string' && hasUnsafeExecutionCharacter(value.shell)) {
|
|
664
|
+
errors.push(`${key}.shell must not contain invisible or control characters.`)
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
if (value.usesShell) {
|
|
668
|
+
requiredString(value, 'shellCommand', errors, key)
|
|
669
|
+
rejectUnresolvedPlaceholder(value.shellCommand, `${key}.shellCommand`, errors)
|
|
670
|
+
if (typeof value.shellCommand === 'string' && hasUnsafeInvisibleCharacter(value.shellCommand)) {
|
|
671
|
+
errors.push(`${key}.shellCommand must not contain invisible or control characters.`)
|
|
672
|
+
} else if (typeof value.shellCommand === 'string' && sanitizeString(value.shellCommand) !== value.shellCommand) {
|
|
673
|
+
errors.push(`${key}.shellCommand must not contain inline secret-like values. Put safe placeholders in env.`)
|
|
674
|
+
}
|
|
675
|
+
} else if (!Array.isArray(value.argv) || value.argv.length === 0) {
|
|
676
|
+
errors.push(`${key}.argv must be a non-empty array unless usesShell is true.`)
|
|
677
|
+
} else {
|
|
678
|
+
validateStringArray(value, 'argv', errors, key)
|
|
679
|
+
for (const [index, arg] of value.argv.slice(0, MAX_MANIFEST_ARRAY_ENTRIES).entries()) {
|
|
680
|
+
rejectUnresolvedPlaceholder(arg, `${key}.argv[${index}]`, errors)
|
|
681
|
+
}
|
|
682
|
+
if (value.argv.some(hasUnsafeExecutionCharacter)) {
|
|
683
|
+
errors.push(`${key}.argv must not contain invisible or control characters.`)
|
|
684
|
+
} else if (JSON.stringify(sanitizeForReport(value.argv)) !== JSON.stringify(value.argv)) {
|
|
685
|
+
errors.push(`${key}.argv must not contain inline secret-like values. Put safe placeholders in env.`)
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
if (value.env !== undefined) {
|
|
689
|
+
if (!value.env || typeof value.env !== 'object' || Array.isArray(value.env)) {
|
|
690
|
+
errors.push(`${key}.env must be an object when present.`)
|
|
691
|
+
} else {
|
|
692
|
+
const environmentEntries = Object.entries(value.env)
|
|
693
|
+
if (environmentEntries.length > MAX_MANIFEST_ARRAY_ENTRIES) {
|
|
694
|
+
errors.push(`${key}.env must contain at most ${MAX_MANIFEST_ARRAY_ENTRIES} entries.`)
|
|
695
|
+
}
|
|
696
|
+
for (const [name, envValue] of environmentEntries.slice(0, MAX_MANIFEST_ARRAY_ENTRIES)) {
|
|
697
|
+
if (!ENV_NAME_PATTERN.test(name)) {
|
|
698
|
+
errors.push(`${key}.env contains invalid variable name ${JSON.stringify(name)}.`)
|
|
699
|
+
}
|
|
700
|
+
if (typeof envValue !== 'string') errors.push(`${key}.env.${name} must be a string.`)
|
|
701
|
+
const validatePlaceholder = !(options.datadogClean && name.startsWith('DD_'))
|
|
702
|
+
if (typeof envValue === 'string' && hasUnsafeExecutionCharacter(envValue)) {
|
|
703
|
+
errors.push(`${key}.env.${name} must not contain invisible or control characters.`)
|
|
704
|
+
} else if (validatePlaceholder && typeof envValue === 'string' && containsSecretValue(name, envValue) &&
|
|
705
|
+
envValue !== SECRET_PLACEHOLDER) {
|
|
706
|
+
errors.push(`${key}.env.${name} must use the safe placeholder ${JSON.stringify(SECRET_PLACEHOLDER)}.`)
|
|
707
|
+
}
|
|
708
|
+
rejectUnresolvedPlaceholder(envValue, `${key}.env.${name}`, errors)
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
if (value.requiredEnvVars !== undefined) {
|
|
713
|
+
if (Array.isArray(value.requiredEnvVars)) {
|
|
714
|
+
validateArrayLimit(value, 'requiredEnvVars', MAX_MANIFEST_ARRAY_ENTRIES, errors, key)
|
|
715
|
+
for (const [index] of value.requiredEnvVars.slice(0, MAX_MANIFEST_ARRAY_ENTRIES).entries()) {
|
|
716
|
+
requiredString(value.requiredEnvVars, index, errors, `${key}.requiredEnvVars`)
|
|
717
|
+
}
|
|
718
|
+
} else {
|
|
719
|
+
errors.push(`${key}.requiredEnvVars must be an array when present.`)
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
optionalAbsolutePathArray(value, 'outputPaths', errors, key)
|
|
723
|
+
if (value.timeoutMs !== undefined && (!Number.isFinite(value.timeoutMs) || value.timeoutMs <= 0)) {
|
|
724
|
+
errors.push(`${key}.timeoutMs must be a positive number when present.`)
|
|
725
|
+
} else if (value.timeoutMs > MAX_COMMAND_TIMEOUT_MS) {
|
|
726
|
+
errors.push(`${key}.timeoutMs must not exceed ${MAX_COMMAND_TIMEOUT_MS} ms.`)
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
function containsSecretValue (name, value) {
|
|
731
|
+
if (SAFE_SECRET_FIELD_VALUES.has(value.toLowerCase())) return false
|
|
732
|
+
return isSensitiveName(name) || sanitizeString(value) !== value
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
function rejectUnresolvedPlaceholder (value, key, errors) {
|
|
736
|
+
if (typeof value !== 'string' || !UNRESOLVED_PLACEHOLDER_PATTERN.test(value)) return
|
|
737
|
+
errors.push(`${key} contains an unresolved placeholder. Resolve it before live validation.`)
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
function requiredObject (target, field, errors, prefix = '') {
|
|
741
|
+
const value = target && target[field]
|
|
742
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
|
743
|
+
errors.push(`${join(prefix, field)} must be an object.`)
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
function requiredArray (target, field, errors, prefix = '') {
|
|
748
|
+
if (!Array.isArray(target && target[field])) {
|
|
749
|
+
errors.push(`${join(prefix, field)} must be an array.`)
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
function requiredString (target, field, errors, prefix = '') {
|
|
754
|
+
if (typeof (target && target[field]) !== 'string' || target[field].length === 0) {
|
|
755
|
+
errors.push(`${join(prefix, field)} must be a non-empty string.`)
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
function enumString (target, field, values, errors, prefix = '') {
|
|
760
|
+
if (!values.has(target && target[field])) {
|
|
761
|
+
errors.push(`${join(prefix, field)} must be one of: ${[...values].join(', ')}.`)
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
function requiredAbsolutePath (target, field, errors, prefix = '') {
|
|
766
|
+
const value = target && target[field]
|
|
767
|
+
if (typeof value !== 'string' || !path.isAbsolute(value)) {
|
|
768
|
+
errors.push(`${join(prefix, field)} must be an absolute path.`)
|
|
769
|
+
} else if (hasUnsafeExecutionCharacter(value)) {
|
|
770
|
+
errors.push(`${join(prefix, field)} must not contain invisible or control characters.`)
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
function optionalAbsolutePath (target, field, errors, prefix = '') {
|
|
775
|
+
const value = target && target[field]
|
|
776
|
+
if (value === undefined || value === null) return
|
|
777
|
+
if (typeof value !== 'string' || !path.isAbsolute(value)) {
|
|
778
|
+
errors.push(`${join(prefix, field)} must be an absolute path when present.`)
|
|
779
|
+
} else if (hasUnsafeExecutionCharacter(value)) {
|
|
780
|
+
errors.push(`${join(prefix, field)} must not contain invisible or control characters.`)
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
function optionalAbsolutePathArray (target, field, errors, prefix = '') {
|
|
785
|
+
const value = target && target[field]
|
|
786
|
+
if (value === undefined) return
|
|
787
|
+
if (!Array.isArray(value)) {
|
|
788
|
+
errors.push(`${join(prefix, field)} must be an array when present.`)
|
|
789
|
+
return
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
validateArrayLimit(target, field, MAX_MANIFEST_ARRAY_ENTRIES, errors, prefix)
|
|
793
|
+
for (const [index, item] of value.slice(0, MAX_MANIFEST_ARRAY_ENTRIES).entries()) {
|
|
794
|
+
if (typeof item !== 'string' || !path.isAbsolute(item)) {
|
|
795
|
+
errors.push(`${join(prefix, field)}[${index}] must be an absolute path.`)
|
|
796
|
+
} else if (hasUnsafeExecutionCharacter(item)) {
|
|
797
|
+
errors.push(`${join(prefix, field)}[${index}] must not contain invisible or control characters.`)
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
function validateStringArray (target, field, errors, prefix = '') {
|
|
803
|
+
const value = target && target[field]
|
|
804
|
+
if (!Array.isArray(value)) return
|
|
805
|
+
|
|
806
|
+
validateArrayLimit(target, field, MAX_MANIFEST_ARRAY_ENTRIES, errors, prefix)
|
|
807
|
+
for (const [index, item] of value.slice(0, MAX_MANIFEST_ARRAY_ENTRIES).entries()) {
|
|
808
|
+
if (typeof item !== 'string') {
|
|
809
|
+
errors.push(`${join(prefix, field)}[${index}] must be a string.`)
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
function validateArrayLimit (target, field, limit, errors, prefix = '') {
|
|
815
|
+
const value = target && target[field]
|
|
816
|
+
if (Array.isArray(value) && value.length > limit) {
|
|
817
|
+
errors.push(`${join(prefix, field)} must contain at most ${limit} entries.`)
|
|
818
|
+
}
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
function limitedArray (value, limit) {
|
|
822
|
+
return Array.isArray(value) ? value.slice(0, limit) : []
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
function createErrorCollector () {
|
|
826
|
+
const errors = []
|
|
827
|
+
let omitted = 0
|
|
828
|
+
Object.defineProperties(errors, {
|
|
829
|
+
push: {
|
|
830
|
+
value (...messages) {
|
|
831
|
+
for (const message of messages) {
|
|
832
|
+
if (this.length < MAX_VALIDATION_ERRORS - 1) {
|
|
833
|
+
Array.prototype.push.call(this, message)
|
|
834
|
+
} else {
|
|
835
|
+
omitted++
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
return this.length
|
|
839
|
+
},
|
|
840
|
+
},
|
|
841
|
+
finalize: {
|
|
842
|
+
value () {
|
|
843
|
+
if (omitted > 0) {
|
|
844
|
+
Array.prototype.push.call(this, `${omitted} additional validation error(s) omitted.`)
|
|
845
|
+
}
|
|
846
|
+
return this
|
|
847
|
+
},
|
|
848
|
+
},
|
|
849
|
+
})
|
|
850
|
+
return errors
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
function join (prefix, field) {
|
|
854
|
+
return prefix ? `${prefix}.${field}` : field
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
module.exports = {
|
|
858
|
+
MAX_FRAMEWORKS,
|
|
859
|
+
MAX_REPRESENTATIVE_TESTS,
|
|
860
|
+
MAX_VALIDATION_ERRORS,
|
|
861
|
+
validateManifest,
|
|
862
|
+
}
|