@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,299 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const crypto = require('node:crypto')
|
|
4
|
+
const fs = require('node:fs')
|
|
5
|
+
const path = require('node:path')
|
|
6
|
+
|
|
7
|
+
const { getCommandOutputPaths } = require('./command-output-policy')
|
|
8
|
+
const { getCommandExecutionSettings } = require('./command-runner')
|
|
9
|
+
const { bindManifestExecutables, getManifestCommands } = require('./executable')
|
|
10
|
+
const { getFixtureRecipeDigests } = require('./offline-fixtures')
|
|
11
|
+
const { sanitizeForReport } = require('./redaction')
|
|
12
|
+
|
|
13
|
+
const APPROVAL_DIGEST_PATTERN = /^[a-f0-9]{64}$/
|
|
14
|
+
const OFFLINE_FIXTURE_NONCE_PATTERN = /^[a-f0-9]{32}$/
|
|
15
|
+
const PACKAGE_SNAPSHOT_EXCLUDED_NAMES = new Set(['.git', '.nyc_output', 'node_modules'])
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Binds an approval to the exact manifest bytes and live validator options.
|
|
19
|
+
*
|
|
20
|
+
* @param {object} input approval inputs
|
|
21
|
+
* @param {object} input.manifest loaded manifest
|
|
22
|
+
* @param {string} input.out validation output directory
|
|
23
|
+
* @param {string[]} [input.selectedFrameworkIds] selected framework ids
|
|
24
|
+
* @param {string|null} [input.requestedScenario] selected scenario
|
|
25
|
+
* @param {string} input.offlineFixtureNonce random fixture-root nonce shown in the execution plan
|
|
26
|
+
* @param {boolean} [input.keepTempFiles] whether generated files are retained
|
|
27
|
+
* @param {boolean} [input.verbose] whether command progress is printed
|
|
28
|
+
* @returns {string} SHA-256 approval digest
|
|
29
|
+
*/
|
|
30
|
+
function getApprovalDigest ({
|
|
31
|
+
manifest,
|
|
32
|
+
out,
|
|
33
|
+
selectedFrameworkIds = [],
|
|
34
|
+
requestedScenario = null,
|
|
35
|
+
offlineFixtureNonce,
|
|
36
|
+
keepTempFiles = false,
|
|
37
|
+
verbose = false,
|
|
38
|
+
}) {
|
|
39
|
+
const approvalJson = serializeApprovalMaterial({
|
|
40
|
+
manifest,
|
|
41
|
+
out,
|
|
42
|
+
selectedFrameworkIds,
|
|
43
|
+
requestedScenario,
|
|
44
|
+
offlineFixtureNonce,
|
|
45
|
+
keepTempFiles,
|
|
46
|
+
verbose,
|
|
47
|
+
})
|
|
48
|
+
return crypto.createHash('sha256').update(approvalJson).digest('hex')
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Builds the complete, inspectable material covered by one approval fingerprint.
|
|
53
|
+
*
|
|
54
|
+
* Secret-like values are redacted for the artifact while the raw manifest digest still binds their exact bytes.
|
|
55
|
+
*
|
|
56
|
+
* @param {object} input approval inputs
|
|
57
|
+
* @param {object} input.manifest loaded validation manifest
|
|
58
|
+
* @param {string} input.out validation output directory
|
|
59
|
+
* @param {string[]} [input.selectedFrameworkIds] selected framework identifiers
|
|
60
|
+
* @param {string|null} [input.requestedScenario] selected validation scenario
|
|
61
|
+
* @param {string} input.offlineFixtureNonce private offline fixture nonce
|
|
62
|
+
* @param {boolean} [input.keepTempFiles] whether generated files remain after validation
|
|
63
|
+
* @param {boolean} [input.verbose] whether verbose validation output is enabled
|
|
64
|
+
* @returns {object} deterministic approval material
|
|
65
|
+
*/
|
|
66
|
+
function getApprovalMaterial ({
|
|
67
|
+
manifest,
|
|
68
|
+
out,
|
|
69
|
+
selectedFrameworkIds = [],
|
|
70
|
+
requestedScenario = null,
|
|
71
|
+
offlineFixtureNonce,
|
|
72
|
+
keepTempFiles = false,
|
|
73
|
+
verbose = false,
|
|
74
|
+
}) {
|
|
75
|
+
if (!OFFLINE_FIXTURE_NONCE_PATTERN.test(String(offlineFixtureNonce || ''))) {
|
|
76
|
+
throw new Error('Invalid offline fixture nonce. Render a fresh plan with --print-plan.')
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const validationDirectory = __dirname
|
|
80
|
+
const packageRoot = path.resolve(validationDirectory, '..', '..')
|
|
81
|
+
const packageJsonPath = path.join(packageRoot, 'package.json')
|
|
82
|
+
const packageMetadata = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'))
|
|
83
|
+
const packageFiles = getPackageFiles(packageRoot, [
|
|
84
|
+
manifest.__path,
|
|
85
|
+
out,
|
|
86
|
+
path.join(packageRoot, '.junit-tmp'),
|
|
87
|
+
])
|
|
88
|
+
const executableIdentities = bindManifestExecutables(manifest)
|
|
89
|
+
|
|
90
|
+
return {
|
|
91
|
+
schemaVersion: 1,
|
|
92
|
+
sharingWarning: 'Internal diagnostic material. Review repository paths, commands, and CI metadata before sharing.',
|
|
93
|
+
validator: {
|
|
94
|
+
package: packageMetadata.name,
|
|
95
|
+
version: packageMetadata.version,
|
|
96
|
+
packageRoot,
|
|
97
|
+
coveredFiles: packageFiles.map(filename => ({
|
|
98
|
+
path: path.relative(packageRoot, filename).split(path.sep).join('/'),
|
|
99
|
+
sha256: getFileDigest(filename),
|
|
100
|
+
})),
|
|
101
|
+
},
|
|
102
|
+
manifest: {
|
|
103
|
+
path: path.resolve(manifest.__path),
|
|
104
|
+
sha256: getManifestDigest(manifest),
|
|
105
|
+
},
|
|
106
|
+
selection: {
|
|
107
|
+
frameworks: [...selectedFrameworkIds],
|
|
108
|
+
scenario: requestedScenario,
|
|
109
|
+
},
|
|
110
|
+
validation: {
|
|
111
|
+
outputDirectory: path.resolve(out),
|
|
112
|
+
offlineFixtureNonce,
|
|
113
|
+
keepTemporaryFiles: keepTempFiles,
|
|
114
|
+
verbose,
|
|
115
|
+
},
|
|
116
|
+
fixtureRecipeDigests: getFixtureRecipeDigests({
|
|
117
|
+
frameworks: manifest.frameworks || [],
|
|
118
|
+
selectedFrameworkIds,
|
|
119
|
+
requestedScenario,
|
|
120
|
+
}),
|
|
121
|
+
commands: getManifestCommands(manifest).map(([id, command]) => getApprovalCommand(id, command)),
|
|
122
|
+
generatedFiles: getGeneratedFileMaterial(manifest),
|
|
123
|
+
executables: executableIdentities,
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Serializes approval material using stable formatting suitable for independent SHA-256 tools.
|
|
129
|
+
*
|
|
130
|
+
* @param {object} input approval inputs
|
|
131
|
+
* @returns {string} UTF-8 JSON text ending in one newline
|
|
132
|
+
*/
|
|
133
|
+
function serializeApprovalMaterial (input) {
|
|
134
|
+
return `${JSON.stringify(getApprovalMaterial(input), null, 2)}\n`
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Returns every regular file owned by the installed dd-trace package.
|
|
139
|
+
*
|
|
140
|
+
* @param {string} packageRoot installed dd-trace package root
|
|
141
|
+
* @param {string[]} excludedPaths generated files or directories outside the package snapshot
|
|
142
|
+
* @returns {string[]} sorted absolute file paths
|
|
143
|
+
*/
|
|
144
|
+
function getPackageFiles (packageRoot, excludedPaths) {
|
|
145
|
+
const files = []
|
|
146
|
+
collectPackageFiles(
|
|
147
|
+
fs.realpathSync(packageRoot),
|
|
148
|
+
excludedPaths.map(resolvePhysicalPath),
|
|
149
|
+
files
|
|
150
|
+
)
|
|
151
|
+
return files.sort()
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Converts one manifest command into its sanitized, execution-relevant approval shape.
|
|
156
|
+
*
|
|
157
|
+
* @param {string} id stable command identifier
|
|
158
|
+
* @param {object} command structured command
|
|
159
|
+
* @returns {object} command approval material
|
|
160
|
+
*/
|
|
161
|
+
function getApprovalCommand (id, command) {
|
|
162
|
+
const shape = {
|
|
163
|
+
id,
|
|
164
|
+
required: command.required !== false,
|
|
165
|
+
usesShell: command.usesShell === true,
|
|
166
|
+
cwd: path.resolve(command.cwd),
|
|
167
|
+
environmentMode: 'clean',
|
|
168
|
+
environment: command.env || {},
|
|
169
|
+
...getCommandExecutionSettings(command),
|
|
170
|
+
outputPaths: getCommandOutputPaths(command),
|
|
171
|
+
}
|
|
172
|
+
if (command.usesShell) {
|
|
173
|
+
shape.shell = command.shell || null
|
|
174
|
+
shape.shellCommand = command.shellCommand
|
|
175
|
+
} else {
|
|
176
|
+
shape.argv = command.argv
|
|
177
|
+
}
|
|
178
|
+
return sanitizeForReport(shape)
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Returns exact generated test source and cleanup policy covered by the manifest digest.
|
|
183
|
+
*
|
|
184
|
+
* @param {object} manifest loaded manifest
|
|
185
|
+
* @returns {object[]} generated file approval material
|
|
186
|
+
*/
|
|
187
|
+
function getGeneratedFileMaterial (manifest) {
|
|
188
|
+
const files = []
|
|
189
|
+
for (const framework of manifest.frameworks || []) {
|
|
190
|
+
const strategy = framework.generatedTestStrategy
|
|
191
|
+
for (const file of strategy?.files || []) {
|
|
192
|
+
const content = `${file.contentLines.join('\n')}\n`
|
|
193
|
+
files.push(sanitizeForReport({
|
|
194
|
+
frameworkId: framework.id,
|
|
195
|
+
path: path.resolve(file.path),
|
|
196
|
+
sha256: crypto.createHash('sha256').update(content).digest('hex'),
|
|
197
|
+
content,
|
|
198
|
+
removeAfterValidation: (strategy.cleanupPaths || []).some(cleanupPath => {
|
|
199
|
+
return path.resolve(cleanupPath) === path.resolve(file.path)
|
|
200
|
+
}),
|
|
201
|
+
}))
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
return files
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Hashes one covered regular file.
|
|
209
|
+
*
|
|
210
|
+
* @param {string} filename absolute filename
|
|
211
|
+
* @returns {string} lowercase SHA-256 digest
|
|
212
|
+
*/
|
|
213
|
+
function getFileDigest (filename) {
|
|
214
|
+
return crypto.createHash('sha256').update(fs.readFileSync(filename)).digest('hex')
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Collects regular package files without following package-internal symbolic links.
|
|
219
|
+
*
|
|
220
|
+
* @param {string} directory current package directory
|
|
221
|
+
* @param {string[]} excludedPaths generated paths omitted from the package snapshot
|
|
222
|
+
* @param {string[]} files collected files
|
|
223
|
+
*/
|
|
224
|
+
function collectPackageFiles (directory, excludedPaths, files) {
|
|
225
|
+
for (const entry of fs.readdirSync(directory, { withFileTypes: true })) {
|
|
226
|
+
const filename = path.join(directory, entry.name)
|
|
227
|
+
if (PACKAGE_SNAPSHOT_EXCLUDED_NAMES.has(entry.name) || isExcludedPackagePath(filename, excludedPaths)) continue
|
|
228
|
+
if (entry.isDirectory()) {
|
|
229
|
+
collectPackageFiles(filename, excludedPaths, files)
|
|
230
|
+
} else if (entry.isFile()) {
|
|
231
|
+
files.push(filename)
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Checks whether a package path belongs to a generated approval input or output.
|
|
238
|
+
*
|
|
239
|
+
* @param {string} filename package path
|
|
240
|
+
* @param {string[]} excludedPaths generated paths omitted from the package snapshot
|
|
241
|
+
* @returns {boolean} whether the path is excluded
|
|
242
|
+
*/
|
|
243
|
+
function isExcludedPackagePath (filename, excludedPaths) {
|
|
244
|
+
return excludedPaths.some(excluded => filename === excluded || filename.startsWith(`${excluded}${path.sep}`))
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Resolves an existing path or its nearest existing ancestor through filesystem aliases.
|
|
249
|
+
*
|
|
250
|
+
* @param {string} filename path that may not exist yet
|
|
251
|
+
* @returns {string} physical path
|
|
252
|
+
*/
|
|
253
|
+
function resolvePhysicalPath (filename) {
|
|
254
|
+
const missingSegments = []
|
|
255
|
+
let existingPath = path.resolve(filename)
|
|
256
|
+
while (!fs.existsSync(existingPath)) {
|
|
257
|
+
missingSegments.unshift(path.basename(existingPath))
|
|
258
|
+
const parent = path.dirname(existingPath)
|
|
259
|
+
if (parent === existingPath) return path.resolve(filename)
|
|
260
|
+
existingPath = parent
|
|
261
|
+
}
|
|
262
|
+
return path.join(fs.realpathSync(existingPath), ...missingSegments)
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Validates an approval digest before live validation executes project code.
|
|
267
|
+
*
|
|
268
|
+
* @param {string} digest supplied approval digest
|
|
269
|
+
* @param {object} input approval inputs
|
|
270
|
+
* @returns {void}
|
|
271
|
+
*/
|
|
272
|
+
function assertApprovalDigest (digest, input) {
|
|
273
|
+
if (!APPROVAL_DIGEST_PATTERN.test(String(digest || ''))) {
|
|
274
|
+
throw new Error('Invalid approved plan SHA-256. Render a fresh plan with --print-plan.')
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
const expected = getApprovalDigest(input)
|
|
278
|
+
if (digest !== expected) {
|
|
279
|
+
throw new Error(
|
|
280
|
+
'The validation manifest or execution options changed after approval. ' +
|
|
281
|
+
'Render a fresh plan with --print-plan and approve that exact plan before live validation.'
|
|
282
|
+
)
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
function getManifestDigest (manifest) {
|
|
287
|
+
if (manifest.__sourceSha256) return manifest.__sourceSha256
|
|
288
|
+
|
|
289
|
+
const serializable = { ...manifest }
|
|
290
|
+
delete serializable.__path
|
|
291
|
+
return crypto.createHash('sha256').update(JSON.stringify(serializable)).digest('hex')
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
module.exports = {
|
|
295
|
+
assertApprovalDigest,
|
|
296
|
+
getApprovalDigest,
|
|
297
|
+
getApprovalMaterial,
|
|
298
|
+
serializeApprovalMaterial,
|
|
299
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const crypto = require('node:crypto')
|
|
4
|
+
|
|
5
|
+
const MAX_PREFIX_LENGTH = 72
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Maps an arbitrary manifest identifier to a bounded, portable, collision-resistant path segment.
|
|
9
|
+
*
|
|
10
|
+
* @param {string} value original identifier
|
|
11
|
+
* @returns {string} artifact path segment
|
|
12
|
+
*/
|
|
13
|
+
function getArtifactId (value) {
|
|
14
|
+
const source = String(value)
|
|
15
|
+
const prefix = source.replaceAll(/[^a-zA-Z0-9._-]+/g, '-').slice(0, MAX_PREFIX_LENGTH) || 'framework'
|
|
16
|
+
const digest = crypto.createHash('sha256').update(source).digest('hex').slice(0, 12)
|
|
17
|
+
return `${prefix}-${digest}`
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
module.exports = { getArtifactId }
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const DEFAULT_MAX_COLLECTION_ENTRIES = 100_000
|
|
4
|
+
const DEFAULT_MAX_NESTING_DEPTH = 128
|
|
5
|
+
const DEFAULT_MAX_STRING_BYTES = 64 * 1024
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Parses JSON only after a no-allocation scan bounds nesting, strings, and collection cardinality.
|
|
9
|
+
*
|
|
10
|
+
* @param {Buffer|string} source encoded JSON
|
|
11
|
+
* @param {object} [options] parser limits
|
|
12
|
+
* @param {string} [options.label] value label used in errors
|
|
13
|
+
* @param {number} [options.maxCollectionEntries] aggregate array/object entries
|
|
14
|
+
* @param {number} [options.maxNestingDepth] maximum container nesting
|
|
15
|
+
* @param {number} [options.maxStringBytes] maximum encoded string bytes
|
|
16
|
+
* @returns {{collectionEntries: number, value: unknown}} parsed value and scanned cardinality
|
|
17
|
+
*/
|
|
18
|
+
function parseBoundedJson (source, options = {}) {
|
|
19
|
+
const buffer = Buffer.isBuffer(source) ? source : Buffer.from(String(source))
|
|
20
|
+
const limits = {
|
|
21
|
+
label: options.label || 'JSON',
|
|
22
|
+
maxCollectionEntries: options.maxCollectionEntries || DEFAULT_MAX_COLLECTION_ENTRIES,
|
|
23
|
+
maxNestingDepth: options.maxNestingDepth || DEFAULT_MAX_NESTING_DEPTH,
|
|
24
|
+
maxStringBytes: options.maxStringBytes || DEFAULT_MAX_STRING_BYTES,
|
|
25
|
+
}
|
|
26
|
+
const collectionEntries = scanJson(buffer, limits)
|
|
27
|
+
return {
|
|
28
|
+
collectionEntries,
|
|
29
|
+
value: JSON.parse(buffer.toString('utf8')),
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Scans JSON bytes without creating one object per delimiter.
|
|
35
|
+
*
|
|
36
|
+
* @param {Buffer} buffer JSON bytes
|
|
37
|
+
* @param {object} limits parser limits
|
|
38
|
+
* @returns {number} aggregate collection entries
|
|
39
|
+
*/
|
|
40
|
+
function scanJson (buffer, limits) {
|
|
41
|
+
const containerTypes = new Uint8Array(limits.maxNestingDepth)
|
|
42
|
+
const arrayHasEntry = new Uint8Array(limits.maxNestingDepth)
|
|
43
|
+
let collectionEntries = 0
|
|
44
|
+
let depth = 0
|
|
45
|
+
let escaped = false
|
|
46
|
+
let inString = false
|
|
47
|
+
let stringBytes = 0
|
|
48
|
+
|
|
49
|
+
for (const byte of buffer) {
|
|
50
|
+
if (inString) {
|
|
51
|
+
stringBytes++
|
|
52
|
+
if (stringBytes > limits.maxStringBytes) {
|
|
53
|
+
throw new Error(`${limits.label} contains a string larger than ${limits.maxStringBytes} bytes.`)
|
|
54
|
+
}
|
|
55
|
+
if (escaped) {
|
|
56
|
+
escaped = false
|
|
57
|
+
} else if (byte === 0x5C) {
|
|
58
|
+
escaped = true
|
|
59
|
+
} else if (byte === 0x22) {
|
|
60
|
+
inString = false
|
|
61
|
+
}
|
|
62
|
+
continue
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (byte === 0x22) {
|
|
66
|
+
inString = true
|
|
67
|
+
stringBytes = 0
|
|
68
|
+
markArrayEntry()
|
|
69
|
+
continue
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const containerIndex = depth - 1
|
|
73
|
+
if (containerIndex >= 0 && containerTypes[containerIndex] === 1 &&
|
|
74
|
+
arrayHasEntry[containerIndex] === 0 && !isJsonWhitespace(byte) && byte !== 0x5D) {
|
|
75
|
+
arrayHasEntry[containerIndex] = 1
|
|
76
|
+
addEntry()
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (byte === 0x5B || byte === 0x7B) {
|
|
80
|
+
if (depth >= limits.maxNestingDepth) {
|
|
81
|
+
throw new Error(`${limits.label} nesting exceeds ${limits.maxNestingDepth}.`)
|
|
82
|
+
}
|
|
83
|
+
containerTypes[depth] = byte === 0x5B ? 1 : 2
|
|
84
|
+
arrayHasEntry[depth] = 0
|
|
85
|
+
depth++
|
|
86
|
+
} else if (byte === 0x5D || byte === 0x7D) {
|
|
87
|
+
if (depth > 0) depth--
|
|
88
|
+
} else if (byte === 0x2C && containerIndex >= 0 && containerTypes[containerIndex] === 1) {
|
|
89
|
+
arrayHasEntry[containerIndex] = 0
|
|
90
|
+
} else if (byte === 0x3A && containerIndex >= 0 && containerTypes[containerIndex] === 2) {
|
|
91
|
+
addEntry()
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return collectionEntries
|
|
96
|
+
|
|
97
|
+
function markArrayEntry () {
|
|
98
|
+
const index = depth - 1
|
|
99
|
+
if (index < 0 || containerTypes[index] !== 1 || arrayHasEntry[index] !== 0) return
|
|
100
|
+
arrayHasEntry[index] = 1
|
|
101
|
+
addEntry()
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function addEntry () {
|
|
105
|
+
collectionEntries++
|
|
106
|
+
if (collectionEntries > limits.maxCollectionEntries) {
|
|
107
|
+
throw new Error(`${limits.label} exceeds ${limits.maxCollectionEntries} aggregate collection entries.`)
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function isJsonWhitespace (byte) {
|
|
113
|
+
return byte === 0x20 || byte === 0x09 || byte === 0x0A || byte === 0x0D
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
module.exports = {
|
|
117
|
+
DEFAULT_MAX_COLLECTION_ENTRIES,
|
|
118
|
+
DEFAULT_MAX_NESTING_DEPTH,
|
|
119
|
+
DEFAULT_MAX_STRING_BYTES,
|
|
120
|
+
parseBoundedJson,
|
|
121
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const {
|
|
4
|
+
getCommandDetails,
|
|
5
|
+
serializeDisplayCommand,
|
|
6
|
+
} = require('./command-runner')
|
|
7
|
+
const { sanitizeEnv } = require('./redaction')
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Builds the normalized CI command metadata shape shared by reports and UI payloads.
|
|
11
|
+
*
|
|
12
|
+
* @param {object} framework manifest framework entry
|
|
13
|
+
* @returns {object|undefined} CI command candidate context when available
|
|
14
|
+
*/
|
|
15
|
+
function buildCiCommandCandidate (framework) {
|
|
16
|
+
const ciWiring = framework.ciWiring || {}
|
|
17
|
+
const command = framework.ciWiringCommand
|
|
18
|
+
|
|
19
|
+
if (!command && !hasCiWiringContext(ciWiring)) return
|
|
20
|
+
|
|
21
|
+
return removeUndefined({
|
|
22
|
+
provider: ciWiring.provider || undefined,
|
|
23
|
+
configFile: ciWiring.configFile || undefined,
|
|
24
|
+
workflow: ciWiring.workflow || undefined,
|
|
25
|
+
job: ciWiring.job || undefined,
|
|
26
|
+
step: ciWiring.step || undefined,
|
|
27
|
+
runner: ciWiring.runner || undefined,
|
|
28
|
+
shell: ciWiring.shell || undefined,
|
|
29
|
+
command: command ? serializeDisplayCommand(command) : ciWiring.command,
|
|
30
|
+
cwd: command?.cwd || ciWiring.workingDirectory,
|
|
31
|
+
whySelected: ciWiring.whySelected || ciWiring.selectionReason || ciWiring.diagnosis,
|
|
32
|
+
replayability: ciWiring.replayability,
|
|
33
|
+
replayBlocker: ciWiring.replayBlocker,
|
|
34
|
+
initialization: ciWiring.initialization,
|
|
35
|
+
env: buildCiEnvSummary(ciWiring, command),
|
|
36
|
+
packageScriptExpansionChain: getFirstArray(
|
|
37
|
+
ciWiring.packageScriptExpansionChain,
|
|
38
|
+
ciWiring.scriptExpansionChain,
|
|
39
|
+
ciWiring.commandExpansion
|
|
40
|
+
),
|
|
41
|
+
runnerToolChain: getFirstArray(
|
|
42
|
+
ciWiring.runnerToolChain,
|
|
43
|
+
ciWiring.toolChain,
|
|
44
|
+
ciWiring.commandChain
|
|
45
|
+
),
|
|
46
|
+
setupCommandIds: ciWiring.setupCommandIds,
|
|
47
|
+
unresolved: ciWiring.unresolved,
|
|
48
|
+
commandDetails: command && getCommandDetails(command),
|
|
49
|
+
})
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function buildCiEnvSummary (ciWiring, command) {
|
|
53
|
+
const summary = removeUndefined({
|
|
54
|
+
workflow: sanitizeEnv(ciWiring.workflowEnv || ciWiring.env?.workflow),
|
|
55
|
+
job: sanitizeEnv(ciWiring.jobEnv || ciWiring.env?.job),
|
|
56
|
+
step: sanitizeEnv(ciWiring.stepEnv || command?.env || ciWiring.env?.step),
|
|
57
|
+
inherited: sanitizeEnv(ciWiring.inheritedEnv),
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
return Object.keys(summary).length > 0 ? summary : undefined
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function hasCiWiringContext (ciWiring) {
|
|
64
|
+
return Object.keys(ciWiring).length > 0
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function getFirstArray (...values) {
|
|
68
|
+
for (const value of values) {
|
|
69
|
+
if (Array.isArray(value) && value.length > 0) return value
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function removeUndefined (object) {
|
|
74
|
+
const result = {}
|
|
75
|
+
for (const [key, value] of Object.entries(object)) {
|
|
76
|
+
if (value !== undefined) result[key] = value
|
|
77
|
+
}
|
|
78
|
+
return result
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
module.exports = {
|
|
82
|
+
buildCiCommandCandidate,
|
|
83
|
+
}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const path = require('node:path')
|
|
4
|
+
|
|
5
|
+
const DEFAULT_CI_SEARCHES = [
|
|
6
|
+
'.github/workflows/*.yml',
|
|
7
|
+
'.github/workflows/*.yaml',
|
|
8
|
+
'.gitlab-ci.yml',
|
|
9
|
+
'.gitlab-ci.yaml',
|
|
10
|
+
'.circleci/config.yml',
|
|
11
|
+
'.circleci/config.yaml',
|
|
12
|
+
'.buildkite/pipeline.yml',
|
|
13
|
+
'.buildkite/pipeline.yaml',
|
|
14
|
+
'bitbucket-pipelines.yml',
|
|
15
|
+
'bitbucket-pipelines.yaml',
|
|
16
|
+
'azure-pipelines.yml',
|
|
17
|
+
'azure-pipelines.yaml',
|
|
18
|
+
'.azure-pipelines/*.yml',
|
|
19
|
+
'.azure-pipelines/*.yaml',
|
|
20
|
+
'Jenkinsfile',
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
function annotateCiDiscovery ({ manifest, diagnosis }) {
|
|
24
|
+
manifest.ciDiscovery = buildCiDiscovery({ manifest, diagnosis })
|
|
25
|
+
|
|
26
|
+
if (manifest.ciDiscovery.contradictions.length === 0) return
|
|
27
|
+
|
|
28
|
+
const warnings = Array.isArray(manifest.warnings) ? manifest.warnings : []
|
|
29
|
+
for (const contradiction of manifest.ciDiscovery.contradictions) {
|
|
30
|
+
const warning = `CI discovery contradiction: ${contradiction}`
|
|
31
|
+
if (!warnings.includes(warning)) warnings.push(warning)
|
|
32
|
+
}
|
|
33
|
+
manifest.warnings = warnings
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function buildCiDiscovery ({ manifest, diagnosis }) {
|
|
37
|
+
const declared = isObject(manifest.ciDiscovery) ? manifest.ciDiscovery : {}
|
|
38
|
+
const staticFound = getStaticWorkflowLocations(diagnosis)
|
|
39
|
+
const declaredFound = normalizeStringArray(declared.found)
|
|
40
|
+
const candidateFound = getManifestWorkflowLocations(manifest)
|
|
41
|
+
const manifestFound = uniqueStrings([...declaredFound, ...candidateFound])
|
|
42
|
+
const searched = normalizeStringArray(declared.searched)
|
|
43
|
+
let method = 'validator-static-diagnosis'
|
|
44
|
+
if (candidateFound.length > 0) method = 'framework-ci-command'
|
|
45
|
+
if (declaredFound.length > 0) method = 'manifest'
|
|
46
|
+
if (typeof declared.method === 'string' && declared.method) method = declared.method
|
|
47
|
+
const found = manifestFound.length > 0 ? manifestFound : staticFound
|
|
48
|
+
const contradictions = getCiDiscoveryContradictions({ manifest, declaredFound: manifestFound, staticFound })
|
|
49
|
+
|
|
50
|
+
return {
|
|
51
|
+
searched: searched.length > 0 ? searched : DEFAULT_CI_SEARCHES,
|
|
52
|
+
found,
|
|
53
|
+
staticFound,
|
|
54
|
+
method,
|
|
55
|
+
warnings: normalizeStringArray(declared.warnings),
|
|
56
|
+
notes: normalizeStringArray(declared.notes),
|
|
57
|
+
contradictions,
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function getManifestWorkflowLocations (manifest) {
|
|
62
|
+
const root = manifest.repository?.root
|
|
63
|
+
const locations = []
|
|
64
|
+
for (const framework of manifest.frameworks || []) {
|
|
65
|
+
const configFile = framework.ciWiring?.configFile
|
|
66
|
+
if (typeof configFile !== 'string') continue
|
|
67
|
+
if (!root || !path.isAbsolute(configFile)) {
|
|
68
|
+
locations.push(configFile)
|
|
69
|
+
continue
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const relative = path.relative(root, configFile)
|
|
73
|
+
locations.push(relative && relative !== '..' && !relative.startsWith(`..${path.sep}`) && !path.isAbsolute(relative)
|
|
74
|
+
? relative.split(path.sep).join('/')
|
|
75
|
+
: configFile)
|
|
76
|
+
}
|
|
77
|
+
return uniqueStrings(locations)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function getFrameworkCiDiscoveryContradiction (framework, manifest) {
|
|
81
|
+
const ciDiscovery = manifest?.ciDiscovery
|
|
82
|
+
if (!ciDiscovery || !Array.isArray(ciDiscovery.staticFound) || ciDiscovery.staticFound.length === 0) return null
|
|
83
|
+
if (!frameworkClaimsNoCi(framework)) return null
|
|
84
|
+
|
|
85
|
+
return {
|
|
86
|
+
reason: 'CI workflow files were found by validator static diagnosis, but this manifest entry says no CI ' +
|
|
87
|
+
'workflow was found. The manifest cannot support a "no CI workflow found" conclusion.',
|
|
88
|
+
recommendation: 'Inspect the discovered CI files with hidden-directory-aware discovery, then update ciWiring, ' +
|
|
89
|
+
'ciWiringCommand, omittedTestCommands, notes, or unresolved blockers before rerunning live validation.',
|
|
90
|
+
ciDiscovery,
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function manifestHasCiDiscoveryContradiction (manifest) {
|
|
95
|
+
return Array.isArray(manifest?.ciDiscovery?.contradictions) &&
|
|
96
|
+
manifest.ciDiscovery.contradictions.length > 0
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function getCiDiscoveryContradictions ({ manifest, declaredFound, staticFound }) {
|
|
100
|
+
if (staticFound.length === 0) return []
|
|
101
|
+
|
|
102
|
+
const contradictions = []
|
|
103
|
+
if (isObject(manifest.ciDiscovery) && declaredFound.length === 0) {
|
|
104
|
+
contradictions.push(
|
|
105
|
+
`manifest ciDiscovery.found is empty, but static diagnosis found ${formatList(staticFound)}`
|
|
106
|
+
)
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
for (const framework of manifest.frameworks || []) {
|
|
110
|
+
if (!frameworkClaimsNoCi(framework)) continue
|
|
111
|
+
contradictions.push(
|
|
112
|
+
`framework ${framework.id || '<unknown>'} records no CI workflow, but static diagnosis found ` +
|
|
113
|
+
formatList(staticFound)
|
|
114
|
+
)
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return contradictions
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function frameworkClaimsNoCi (framework) {
|
|
121
|
+
const ciWiring = framework?.ciWiring
|
|
122
|
+
if (!isObject(ciWiring)) return false
|
|
123
|
+
if (ciWiring.provider === 'none') return true
|
|
124
|
+
|
|
125
|
+
return textClaimsNoCi([
|
|
126
|
+
ciWiring.diagnosis,
|
|
127
|
+
...(Array.isArray(ciWiring.unresolved) ? ciWiring.unresolved : []),
|
|
128
|
+
...(Array.isArray(framework.notes) ? framework.notes : []),
|
|
129
|
+
])
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function textClaimsNoCi (values) {
|
|
133
|
+
return values.some(value => {
|
|
134
|
+
if (typeof value !== 'string') return false
|
|
135
|
+
return /no .*ci .*workflow/i.test(value) ||
|
|
136
|
+
/no .*ci .*configuration/i.test(value) ||
|
|
137
|
+
/no github actions.*gitlab.*circleci.*jenkins/i.test(value)
|
|
138
|
+
})
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function getStaticWorkflowLocations (diagnosis) {
|
|
142
|
+
const results = Array.isArray(diagnosis?.results) ? diagnosis.results : []
|
|
143
|
+
const locations = []
|
|
144
|
+
const seen = new Set()
|
|
145
|
+
|
|
146
|
+
for (const result of results) {
|
|
147
|
+
if (result.title !== 'CI workflow files found' || !Array.isArray(result.locations)) continue
|
|
148
|
+
for (const location of result.locations) {
|
|
149
|
+
if (typeof location !== 'string' || seen.has(location)) continue
|
|
150
|
+
seen.add(location)
|
|
151
|
+
locations.push(location)
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
return locations
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function normalizeStringArray (value) {
|
|
159
|
+
if (!Array.isArray(value)) return []
|
|
160
|
+
return value.filter(item => typeof item === 'string')
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function uniqueStrings (values) {
|
|
164
|
+
return [...new Set(values.filter(value => typeof value === 'string' && value !== ''))]
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function formatList (values) {
|
|
168
|
+
return values.map(value => `"${value}"`).join(', ')
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
function isObject (value) {
|
|
172
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value)
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
module.exports = {
|
|
176
|
+
annotateCiDiscovery,
|
|
177
|
+
buildCiDiscovery,
|
|
178
|
+
getFrameworkCiDiscoveryContradiction,
|
|
179
|
+
getStaticWorkflowLocations,
|
|
180
|
+
manifestHasCiDiscoveryContradiction,
|
|
181
|
+
}
|