dd-trace 6.24.0 → 6.25.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/ci/init.js +2 -22
- package/ext/exporters.js +0 -1
- package/index.d.ts +105 -5
- package/initialize.mjs +5 -2
- package/lambda.d.ts +39 -0
- package/lambda.js +3 -0
- package/package.json +11 -9
- package/packages/datadog-esbuild/index.js +8 -55
- package/packages/datadog-instrumentations/src/aws-lambda.js +88 -0
- package/packages/datadog-instrumentations/src/cucumber.js +5 -2
- package/packages/datadog-instrumentations/src/elevenlabs/activity.js +114 -0
- package/packages/datadog-instrumentations/src/elevenlabs/audio.js +104 -0
- package/packages/datadog-instrumentations/src/elevenlabs/index.js +288 -0
- package/packages/datadog-instrumentations/src/elevenlabs/session.js +444 -0
- package/packages/datadog-instrumentations/src/graphql.js +20 -17
- package/packages/{datadog-esbuild/src/utils.js → datadog-instrumentations/src/helpers/bundler-esm-exports.js} +282 -40
- package/packages/datadog-instrumentations/src/helpers/bundler-transform.js +573 -0
- package/packages/datadog-instrumentations/src/helpers/bundler-utils.js +104 -0
- package/packages/datadog-instrumentations/src/helpers/hook.js +29 -1
- package/packages/datadog-instrumentations/src/helpers/hooks.js +3 -7
- package/packages/datadog-instrumentations/src/helpers/lambda-handler.js +189 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/index.js +2 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentation-registry.js +18 -1
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/async-mutex.js +41 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/elevenlabs.js +25 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/graphql.js +0 -36
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/next.js +40 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/openai-agents-realtime.js +23 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/trpc.js +148 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/target-patterns.json +50 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/targets.json +17 -3
- package/packages/datadog-instrumentations/src/helpers/rewriter/transforms.js +59 -2
- package/packages/datadog-instrumentations/src/ioredis.js +101 -3
- package/packages/datadog-instrumentations/src/next.js +19 -6
- package/packages/datadog-instrumentations/src/openai-agents-realtime.js +149 -0
- package/packages/datadog-instrumentations/src/openai-realtime/audio-accumulator.js +27 -0
- package/packages/datadog-instrumentations/src/openai-realtime/index.js +17 -6
- package/packages/datadog-instrumentations/src/openai-realtime/server-playback.js +887 -0
- package/packages/datadog-instrumentations/src/openai-realtime/session.js +150 -25
- package/packages/datadog-instrumentations/src/openai-realtime/turns.js +29 -2
- package/packages/datadog-instrumentations/src/otel-sdk-trace.js +11 -9
- package/packages/datadog-instrumentations/src/webdriverio.js +12 -12
- package/packages/datadog-plugin-async-mutex/src/index.js +50 -0
- package/packages/datadog-plugin-aws-lambda/src/index.js +106 -0
- package/packages/datadog-plugin-cypress/src/cypress-plugin.js +22 -11
- package/packages/datadog-plugin-elevenlabs/src/index.js +69 -0
- package/packages/datadog-plugin-google-cloud-pubsub/src/consumer.js +10 -7
- package/packages/datadog-plugin-google-cloud-pubsub/src/producer.js +19 -52
- package/packages/datadog-plugin-google-cloud-pubsub/src/pubsub-push-subscription.js +4 -2
- package/packages/datadog-plugin-google-cloud-pubsub/src/pubsub-request-context.js +25 -4
- package/packages/datadog-plugin-http/src/client.js +32 -9
- package/packages/datadog-plugin-http2/src/client.js +38 -13
- package/packages/datadog-plugin-next/src/index.js +112 -14
- package/packages/datadog-plugin-prisma/src/datadog-tracing-helper.js +5 -3
- package/packages/datadog-plugin-trpc/src/index.js +15 -0
- package/packages/datadog-plugin-trpc/src/procedure.js +48 -0
- package/packages/datadog-plugin-trpc/src/request.js +81 -0
- package/packages/datadog-plugin-undici/src/index.js +22 -7
- package/packages/datadog-turbopack/index.js +4 -28
- package/packages/datadog-turbopack/src/loader.js +14 -452
- package/packages/datadog-webpack/index.js +3 -55
- package/packages/dd-trace/src/aiguard/evaluation.js +62 -1
- package/packages/dd-trace/src/aiguard/sdk.js +8 -2
- package/packages/dd-trace/src/aiguard/tags.js +2 -0
- package/packages/dd-trace/src/appsec/blocking/index.js +4 -0
- package/packages/dd-trace/src/appsec/graphql.js +91 -6
- package/packages/dd-trace/src/appsec/recommended.json +1287 -90
- package/packages/dd-trace/src/before-exit.js +32 -0
- package/packages/dd-trace/src/bootstrap.js +5 -3
- package/packages/dd-trace/src/ci-visibility/early-flake-detection/get-known-tests.js +15 -2
- package/packages/dd-trace/src/ci-visibility/exporters/ci-visibility-exporter.js +12 -34
- package/packages/dd-trace/src/ci-visibility/exporters/git/git_metadata.js +41 -13
- package/packages/dd-trace/src/ci-visibility/exporters/request.js +2 -3
- package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +1 -2
- package/packages/dd-trace/src/ci-visibility/requests/get-library-configuration.js +1 -1
- package/packages/dd-trace/src/ci-visibility/telemetry.js +6 -0
- package/packages/dd-trace/src/ci-visibility/test-management/get-test-management-tests.js +1 -1
- package/packages/dd-trace/src/ci-visibility/test-optimization-http-cache-schema.js +9 -134
- package/packages/dd-trace/src/ci-visibility/test-optimization-http-cache.js +11 -156
- package/packages/dd-trace/src/config/config-types.d.ts +3 -0
- package/packages/dd-trace/src/config/defaults.js +5 -0
- package/packages/dd-trace/src/config/generated-config-types.d.ts +42 -2
- package/packages/dd-trace/src/config/index.js +17 -5
- package/packages/dd-trace/src/config/parsers.js +9 -0
- package/packages/dd-trace/src/config/supported-configurations.json +158 -4
- package/packages/dd-trace/src/constants.js +1 -0
- package/packages/dd-trace/src/debugger/pause-duration-histogram.js +2 -1
- package/packages/dd-trace/src/exporter.js +0 -11
- package/packages/dd-trace/src/exporters/common/request.js +81 -48
- package/packages/dd-trace/src/exporters/common/retry.js +12 -7
- package/packages/dd-trace/src/exporters/common/url.js +1 -1
- package/packages/dd-trace/src/id.js +1 -1
- package/packages/dd-trace/src/lambda/facade.js +74 -0
- package/packages/dd-trace/src/lambda/handler.js +3 -41
- package/packages/dd-trace/src/lambda/index.js +38 -15
- package/packages/dd-trace/src/lambda/runtime/patch.js +19 -3
- package/packages/dd-trace/src/lambda/wrap.js +44 -0
- package/packages/dd-trace/src/llmobs/constants/tags.js +2 -0
- package/packages/dd-trace/src/llmobs/experiments/experiment.js +10 -5
- package/packages/dd-trace/src/llmobs/plugins/elevenlabs.js +96 -0
- package/packages/dd-trace/src/llmobs/plugins/genai/util.js +19 -6
- package/packages/dd-trace/src/llmobs/plugins/openai/realtime.js +38 -11
- package/packages/dd-trace/src/llmobs/plugins/vertexai.js +10 -2
- package/packages/dd-trace/src/llmobs/sdk.js +19 -0
- package/packages/dd-trace/src/llmobs/span_processor.js +9 -0
- package/packages/dd-trace/src/llmobs/tagger.js +22 -0
- package/packages/dd-trace/src/log/channels.js +4 -0
- package/packages/dd-trace/src/log/writer.js +6 -1
- package/packages/dd-trace/src/openfeature/agentless_configuration_source.js +4 -0
- package/packages/dd-trace/src/openfeature/configuration_source.js +35 -27
- package/packages/dd-trace/src/openfeature/flag-selection.js +152 -0
- package/packages/dd-trace/src/openfeature/flagging_provider.js +19 -1
- package/packages/dd-trace/src/openfeature/writers/base.js +1 -3
- package/packages/dd-trace/src/opentelemetry/logs/index.js +11 -0
- package/packages/dd-trace/src/opentelemetry/logs/otlp_http_log_exporter.js +1 -1
- package/packages/dd-trace/src/opentelemetry/metrics/index.js +7 -1
- package/packages/dd-trace/src/opentelemetry/metrics/otlp_http_metric_exporter.js +1 -1
- package/packages/dd-trace/src/opentelemetry/metrics/otlp_span_stats_exporter.js +4 -1
- package/packages/dd-trace/src/opentelemetry/otlp/otlp_http_exporter_base.js +19 -1
- package/packages/dd-trace/src/opentelemetry/span-ending-hook.js +5 -1
- package/packages/dd-trace/src/opentelemetry/span-helpers.js +6 -1
- package/packages/dd-trace/src/opentelemetry/span.js +2 -2
- package/packages/dd-trace/src/opentelemetry/startup-config.js +174 -0
- package/packages/dd-trace/src/opentelemetry/trace/otlp_http_trace_exporter.js +1 -1
- package/packages/dd-trace/src/opentelemetry/trace/otlp_transformer.js +7 -1
- package/packages/dd-trace/src/opentracing/propagation/tracestate.js +77 -23
- package/packages/dd-trace/src/opentracing/tracer.js +24 -0
- package/packages/dd-trace/src/otel-thread-ctx.js +28 -31
- package/packages/dd-trace/src/plugin_manager.js +34 -7
- package/packages/dd-trace/src/plugins/ci_plugin.js +41 -10
- package/packages/dd-trace/src/plugins/index.js +6 -0
- package/packages/dd-trace/src/plugins/plugin.js +4 -2
- package/packages/dd-trace/src/plugins/tracing.js +1 -1
- package/packages/dd-trace/src/plugins/util/ci.js +18 -1
- package/packages/dd-trace/src/plugins/util/git-cache.js +4 -4
- package/packages/dd-trace/src/plugins/util/git.js +263 -82
- package/packages/dd-trace/src/plugins/util/http-otel-semantics.js +75 -46
- package/packages/dd-trace/src/plugins/util/inferred_proxy.js +12 -4
- package/packages/dd-trace/src/plugins/util/status-validator.js +23 -10
- package/packages/dd-trace/src/plugins/util/tags.js +6 -0
- package/packages/dd-trace/src/plugins/util/test.js +64 -39
- package/packages/dd-trace/src/plugins/util/url.js +10 -2
- package/packages/dd-trace/src/plugins/util/user-provided-git.js +2 -2
- package/packages/dd-trace/src/plugins/util/web.js +65 -10
- package/packages/dd-trace/src/profiling/webspan-utils.js +6 -5
- package/packages/dd-trace/src/proxy.js +33 -53
- package/packages/dd-trace/src/span_processor.js +20 -0
- package/packages/dd-trace/src/startup-log.js +8 -6
- package/packages/dd-trace/src/telemetry/metrics.js +2 -1
- package/packages/dd-trace/src/tracer.js +0 -2
- package/packages/dd-trace/src/web-tags-cache.js +8 -9
- package/register.js +2 -1
- package/vendor/dist/@apm-js-collab/code-transformer/LICENSE +489 -0
- package/vendor/dist/@datadog/flagging-core/LICENSE +221 -0
- package/vendor/dist/@datadog/flagging-core/index.js +1 -0
- package/vendor/dist/@datadog/openfeature-node-server/LICENSE +21 -1
- package/vendor/dist/@datadog/openfeature-node-server/rules-based/LICENSE +3 -1
- package/vendor/dist/@datadog/sketches-js/LICENSE +263 -0
- package/vendor/dist/@datadog/source-map/LICENSE +1 -0
- package/vendor/dist/@isaacs/ttlcache/LICENSE +13 -0
- package/vendor/dist/@opentelemetry/core/LICENSE +209 -1
- package/vendor/dist/crypto-randomuuid/LICENSE +3 -0
- package/vendor/dist/escape-string-regexp/LICENSE +13 -0
- package/vendor/dist/esquery/LICENSE +2 -0
- package/vendor/dist/https-proxy-agent/LICENSE +80 -1
- package/vendor/dist/istanbul-lib-coverage/LICENSE +2 -0
- package/vendor/dist/jest-docblock/LICENSE +16 -0
- package/vendor/dist/jsonpath-plus/LICENSE +13 -0
- package/vendor/dist/limiter/LICENSE +2 -0
- package/vendor/dist/lodash.sortby/LICENSE +2 -0
- package/vendor/dist/lru-cache/LICENSE +13 -0
- package/vendor/dist/meriyah/LICENSE +13 -0
- package/vendor/dist/module-details-from-path/LICENSE +2 -0
- package/vendor/dist/mutexify/promise/LICENSE +28 -0
- package/vendor/dist/pprof-format/LICENSE +13 -0
- package/vendor/dist/pprof-format/index.js +1 -1
- package/vendor/dist/protobufjs/LICENSE +219 -0
- package/vendor/dist/protobufjs/minimal/LICENSE +219 -0
- package/vendor/dist/proxy-from-env/LICENSE +13 -0
- package/vendor/dist/retry/LICENSE +2 -0
- package/vendor/dist/rfdc/LICENSE +2 -0
- package/vendor/dist/semifies/LICENSE +3 -1
- package/vendor/dist/shell-quote/LICENSE +3 -1
- package/vendor/dist/source-map/LICENSE +1 -0
- package/vendor/dist/source-map/lib/util/LICENSE +1 -0
- package/vendor/dist/tlhunter-sorted-set/LICENSE +2 -0
- package/vendor/dist/ttl-set/LICENSE +28 -0
- package/ci/diagnose.js +0 -2215
- package/ci/runbook.md +0 -299
- package/ci/test-optimization-validation/approval-artifacts.js +0 -175
- package/ci/test-optimization-validation/approval.js +0 -386
- package/ci/test-optimization-validation/artifact-id.js +0 -18
- package/ci/test-optimization-validation/blocker-category.js +0 -24
- package/ci/test-optimization-validation/bounded-json.js +0 -120
- package/ci/test-optimization-validation/ci-command-candidate.js +0 -77
- package/ci/test-optimization-validation/ci-discovery.js +0 -192
- package/ci/test-optimization-validation/ci-package-scripts.js +0 -169
- package/ci/test-optimization-validation/ci-remediation.js +0 -283
- package/ci/test-optimization-validation/cli.js +0 -954
- package/ci/test-optimization-validation/command-blocker.js +0 -377
- package/ci/test-optimization-validation/command-output-policy.js +0 -188
- package/ci/test-optimization-validation/command-runner.js +0 -649
- package/ci/test-optimization-validation/environment.js +0 -88
- package/ci/test-optimization-validation/executable-approval.js +0 -47
- package/ci/test-optimization-validation/executable.js +0 -244
- package/ci/test-optimization-validation/execution-lock.js +0 -70
- package/ci/test-optimization-validation/framework-adapters/cucumber-validation.json +0 -3
- package/ci/test-optimization-validation/framework-adapters/cucumber.js +0 -767
- package/ci/test-optimization-validation/framework-adapters/cypress.js +0 -99
- package/ci/test-optimization-validation/framework-adapters/playwright.js +0 -175
- package/ci/test-optimization-validation/framework-adapters/vitest.js +0 -513
- package/ci/test-optimization-validation/generated-file-policy.js +0 -63
- package/ci/test-optimization-validation/generated-files.js +0 -425
- package/ci/test-optimization-validation/generated-test-contract.js +0 -284
- package/ci/test-optimization-validation/generated-verifier.js +0 -235
- package/ci/test-optimization-validation/literal-environment.js +0 -56
- package/ci/test-optimization-validation/literal-glob.js +0 -52
- package/ci/test-optimization-validation/manifest-loader.js +0 -116
- package/ci/test-optimization-validation/manifest-scaffold.js +0 -1276
- package/ci/test-optimization-validation/manifest-schema.js +0 -695
- package/ci/test-optimization-validation/offline-fixtures.js +0 -335
- package/ci/test-optimization-validation/offline-output.js +0 -406
- package/ci/test-optimization-validation/package-check.js +0 -97
- package/ci/test-optimization-validation/payload-normalizer.js +0 -72
- package/ci/test-optimization-validation/plan-writer.js +0 -541
- package/ci/test-optimization-validation/preflight-runner.js +0 -186
- package/ci/test-optimization-validation/project-build-artifact.js +0 -31
- package/ci/test-optimization-validation/redaction.js +0 -319
- package/ci/test-optimization-validation/report-writer.js +0 -666
- package/ci/test-optimization-validation/result-semantics.js +0 -103
- package/ci/test-optimization-validation/runner-command.js +0 -264
- package/ci/test-optimization-validation/runner-contract.js +0 -695
- package/ci/test-optimization-validation/safe-files.js +0 -202
- package/ci/test-optimization-validation/scenarios/auto-test-retries.js +0 -171
- package/ci/test-optimization-validation/scenarios/basic-reporting.js +0 -407
- package/ci/test-optimization-validation/scenarios/ci-wiring.js +0 -666
- package/ci/test-optimization-validation/scenarios/early-flake-detection.js +0 -142
- package/ci/test-optimization-validation/scenarios/helpers.js +0 -621
- package/ci/test-optimization-validation/scenarios/test-management.js +0 -219
- package/ci/test-optimization-validation/source-text.js +0 -84
- package/ci/test-optimization-validation/static-diagnosis.js +0 -166
- package/ci/test-optimization-validation/test-output.js +0 -120
- package/ci/test-optimization-validation/validation-blocker.js +0 -21
- package/ci/validate-test-optimization.js +0 -3
- package/packages/datadog-esbuild/src/resolver.js +0 -284
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/index.js +0 -156
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/msgpack-to-json.js +0 -287
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/payload-projection.js +0 -84
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/sink.js +0 -368
- package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/writer.js +0 -59
|
@@ -1,235 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const fs = require('node:fs')
|
|
4
|
-
const path = require('node:path')
|
|
5
|
-
|
|
6
|
-
const { BLOCKER_CATEGORIES, getBlockerDomain } = require('./blocker-category')
|
|
7
|
-
const { getCommandBlocker } = require('./command-blocker')
|
|
8
|
-
const { runCommand, serializeDisplayCommand } = require('./command-runner')
|
|
9
|
-
const {
|
|
10
|
-
cleanupGeneratedRuntimeFiles,
|
|
11
|
-
writeGeneratedFiles,
|
|
12
|
-
} = require('./generated-files')
|
|
13
|
-
const { getGeneratedCommand } = require('./runner-command')
|
|
14
|
-
const { frameworkOutDir } = require('./scenarios/helpers')
|
|
15
|
-
const { getObservedTestCount } = require('./test-output')
|
|
16
|
-
const { getValidationBlockerEvidence } = require('./validation-blocker')
|
|
17
|
-
|
|
18
|
-
const GENERATED_SCENARIO_BY_FEATURE = {
|
|
19
|
-
efd: 'basic-pass',
|
|
20
|
-
atr: 'atr-fail-once',
|
|
21
|
-
'test-management': 'test-management-target',
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Verifies generated scenario commands without Datadog initialization.
|
|
26
|
-
*
|
|
27
|
-
* @param {object} input verification inputs
|
|
28
|
-
* @param {object} input.framework manifest framework entry
|
|
29
|
-
* @param {string} input.out validation output directory
|
|
30
|
-
* @param {object} input.options validator options
|
|
31
|
-
* @returns {Promise<{ok: boolean, failure?: object}>} verification outcome
|
|
32
|
-
*/
|
|
33
|
-
async function verifyGeneratedTestStrategy ({ framework, out, options }) {
|
|
34
|
-
const strategy = framework.generatedTestStrategy
|
|
35
|
-
if (!strategy || !['planned', 'verified'].includes(strategy.status)) return { ok: true }
|
|
36
|
-
|
|
37
|
-
const evidence = {
|
|
38
|
-
scenarios: [],
|
|
39
|
-
}
|
|
40
|
-
const artifacts = []
|
|
41
|
-
const startedAt = Date.now()
|
|
42
|
-
|
|
43
|
-
try {
|
|
44
|
-
cleanupGeneratedRuntimeFiles(framework)
|
|
45
|
-
|
|
46
|
-
for (const scenario of getScenariosToVerify(strategy.scenarios, options.scenarios)) {
|
|
47
|
-
cleanupGeneratedRuntimeFiles(framework)
|
|
48
|
-
writeGeneratedFiles(framework, scenario)
|
|
49
|
-
const command = getGeneratedCommand(framework, scenario)
|
|
50
|
-
const outDir = frameworkOutDir(out, framework, `generated-verification-${scenario.id}`)
|
|
51
|
-
// Generated commands run serially because fail-once state and cleanup are scenario-local.
|
|
52
|
-
// eslint-disable-next-line no-await-in-loop
|
|
53
|
-
const result = await runCommand(command, {
|
|
54
|
-
artifactRoot: out,
|
|
55
|
-
envMode: 'clean',
|
|
56
|
-
label: `${framework.id}:generated-verification:${scenario.id}`,
|
|
57
|
-
outDir,
|
|
58
|
-
repositoryRoot: options.repositoryRoot,
|
|
59
|
-
requireExecutableApproval: options.requireExecutableApproval,
|
|
60
|
-
verbose: options.verbose,
|
|
61
|
-
})
|
|
62
|
-
const observedTestCount = getObservedTestCount(framework.framework, result.stdout, result.stderr)
|
|
63
|
-
const expected = scenario.expectedWithoutDatadog
|
|
64
|
-
const failOnceStateCreated = scenario.id === 'atr-fail-once'
|
|
65
|
-
? getGeneratedRuntimeFileStatus(strategy)
|
|
66
|
-
: undefined
|
|
67
|
-
const scenarioEvidence = {
|
|
68
|
-
id: scenario.id,
|
|
69
|
-
command: serializeDisplayCommand(command),
|
|
70
|
-
exitCode: result.exitCode,
|
|
71
|
-
expectedExitCode: expected.exitCode,
|
|
72
|
-
observedTestCount,
|
|
73
|
-
expectedTestCount: expected.observedTestCount,
|
|
74
|
-
localAdjustments: command.localAdjustments || [],
|
|
75
|
-
}
|
|
76
|
-
if (failOnceStateCreated !== undefined) scenarioEvidence.failOnceStateCreated = failOnceStateCreated
|
|
77
|
-
evidence.scenarios.push(scenarioEvidence)
|
|
78
|
-
artifacts.push(...Object.values(result.artifacts))
|
|
79
|
-
|
|
80
|
-
const observedWrongTestCount = observedTestCount !== null &&
|
|
81
|
-
observedTestCount !== expected.observedTestCount
|
|
82
|
-
if (result.timedOut || result.exitCode !== expected.exitCode ||
|
|
83
|
-
observedWrongTestCount || failOnceStateCreated === false) {
|
|
84
|
-
cleanupGeneratedRuntimeFiles(framework)
|
|
85
|
-
return getVerificationFailure(
|
|
86
|
-
framework,
|
|
87
|
-
evidence,
|
|
88
|
-
artifacts,
|
|
89
|
-
scenarioEvidence,
|
|
90
|
-
result,
|
|
91
|
-
observedTestCount
|
|
92
|
-
)
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
cleanupGeneratedRuntimeFiles(framework)
|
|
97
|
-
strategy.status = 'verified'
|
|
98
|
-
strategy.verification = {
|
|
99
|
-
source: 'validator',
|
|
100
|
-
ran: true,
|
|
101
|
-
durationMs: Date.now() - startedAt,
|
|
102
|
-
observedScenarios: evidence.scenarios,
|
|
103
|
-
cleanupCompleted: true,
|
|
104
|
-
}
|
|
105
|
-
return { ok: true }
|
|
106
|
-
} catch (error) {
|
|
107
|
-
cleanupGeneratedRuntimeFiles(framework)
|
|
108
|
-
const blockerEvidence = getValidationBlockerEvidence(error)
|
|
109
|
-
return {
|
|
110
|
-
ok: false,
|
|
111
|
-
failure: {
|
|
112
|
-
frameworkId: framework.id,
|
|
113
|
-
scenario: 'generated-test-verification',
|
|
114
|
-
status: blockerEvidence ? 'blocked' : 'error',
|
|
115
|
-
diagnosis: 'The validator could not run the temporary validation test as expected. No advanced-feature ' +
|
|
116
|
-
`conclusion was reached: ${error.message || error}`,
|
|
117
|
-
evidence: { ...evidence, ...blockerEvidence },
|
|
118
|
-
artifacts,
|
|
119
|
-
},
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* Selects only generated tests required by the requested advanced checks.
|
|
126
|
-
*
|
|
127
|
-
* @param {object[]} scenarios generated test scenarios
|
|
128
|
-
* @param {Set<string>} [selectedFeatures] validator scenario selection
|
|
129
|
-
* @returns {object[]} generated scenarios to verify
|
|
130
|
-
*/
|
|
131
|
-
function getScenariosToVerify (scenarios, selectedFeatures) {
|
|
132
|
-
if (!(selectedFeatures instanceof Set)) return scenarios
|
|
133
|
-
|
|
134
|
-
const selectedScenarioIds = new Set()
|
|
135
|
-
for (const feature of selectedFeatures) {
|
|
136
|
-
const scenarioId = GENERATED_SCENARIO_BY_FEATURE[feature]
|
|
137
|
-
if (scenarioId) selectedScenarioIds.add(scenarioId)
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
if (selectedScenarioIds.size === 0) return scenarios
|
|
141
|
-
return scenarios.filter(scenario => selectedScenarioIds.has(scenario.id))
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* Builds a failure when a generated scenario does not behave as declared.
|
|
146
|
-
*
|
|
147
|
-
* @param {object} framework manifest framework entry
|
|
148
|
-
* @param {object} evidence collected verification evidence
|
|
149
|
-
* @param {string[]} artifacts command artifacts
|
|
150
|
-
* @param {object} scenario failed scenario evidence
|
|
151
|
-
* @param {object} result command result
|
|
152
|
-
* @param {number|null} observedTestCount observed generated test count
|
|
153
|
-
* @returns {{ok: false, failure: object}} generated verification failure
|
|
154
|
-
*/
|
|
155
|
-
function getVerificationFailure (framework, evidence, artifacts, scenario, result, observedTestCount) {
|
|
156
|
-
const commandFailure = getCommandBlocker(result, {
|
|
157
|
-
browserRequired: framework.browserRequired,
|
|
158
|
-
framework: framework.framework,
|
|
159
|
-
packageJson: framework.project.packageJson,
|
|
160
|
-
testsRan: Number.isInteger(observedTestCount) && observedTestCount > 0,
|
|
161
|
-
})
|
|
162
|
-
if (commandFailure) {
|
|
163
|
-
const blockerCategory = commandFailure.blockerCategory
|
|
164
|
-
const domain = getBlockerDomain(blockerCategory)
|
|
165
|
-
return {
|
|
166
|
-
ok: false,
|
|
167
|
-
failure: {
|
|
168
|
-
frameworkId: framework.id,
|
|
169
|
-
scenario: 'generated-test-verification',
|
|
170
|
-
status: 'blocked',
|
|
171
|
-
diagnosis: `${commandFailure.summary} Advanced-feature validation could not start reliably.`,
|
|
172
|
-
evidence: { ...evidence, blockerCategory, commandFailure, domain, validationIncomplete: true },
|
|
173
|
-
artifacts,
|
|
174
|
-
},
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
let reason
|
|
178
|
-
if (result.timedOut) {
|
|
179
|
-
reason = 'timed out'
|
|
180
|
-
} else if (scenario.id === 'atr-fail-once' && scenario.failOnceStateCreated === false) {
|
|
181
|
-
reason = 'failed without creating its declared fail-once state file, so it failed for an unrelated reason'
|
|
182
|
-
} else {
|
|
183
|
-
reason = `exited ${scenario.exitCode} with ${formatObservedCount(scenario.observedTestCount)}; expected exit ` +
|
|
184
|
-
`${scenario.expectedExitCode} and ${scenario.expectedTestCount} test`
|
|
185
|
-
}
|
|
186
|
-
return {
|
|
187
|
-
ok: false,
|
|
188
|
-
failure: {
|
|
189
|
-
frameworkId: framework.id,
|
|
190
|
-
scenario: 'generated-test-verification',
|
|
191
|
-
status: 'error',
|
|
192
|
-
diagnosis: `Temporary validation test "${scenario.id}" ${reason}. No advanced-feature conclusion was reached.`,
|
|
193
|
-
evidence: {
|
|
194
|
-
...evidence,
|
|
195
|
-
blockerCategory: BLOCKER_CATEGORIES.VALIDATOR_LIMITATION,
|
|
196
|
-
validationIncomplete: true,
|
|
197
|
-
},
|
|
198
|
-
artifacts,
|
|
199
|
-
},
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
/**
|
|
204
|
-
* Checks a declared generated runtime state file when the adapter uses one.
|
|
205
|
-
*
|
|
206
|
-
* @param {object} strategy generated test strategy
|
|
207
|
-
* @returns {boolean|undefined} whether a declared runtime file exists, or undefined when none is required
|
|
208
|
-
*/
|
|
209
|
-
function getGeneratedRuntimeFileStatus (strategy) {
|
|
210
|
-
const generatedFiles = new Set((strategy.files || []).map(file => path.resolve(file.path)))
|
|
211
|
-
let expectsRuntimeFile = false
|
|
212
|
-
if (strategy.cleanupPaths) {
|
|
213
|
-
for (const cleanupPath of strategy.cleanupPaths) {
|
|
214
|
-
const filename = path.resolve(cleanupPath)
|
|
215
|
-
if (generatedFiles.has(filename)) continue
|
|
216
|
-
expectsRuntimeFile = true
|
|
217
|
-
try {
|
|
218
|
-
const stat = fs.lstatSync(filename)
|
|
219
|
-
if (!stat.isSymbolicLink() && stat.isFile()) return true
|
|
220
|
-
} catch {}
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
return expectsRuntimeFile ? false : undefined
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
/**
|
|
227
|
-
* Formats a parsed test count for a customer-facing diagnosis.
|
|
228
|
-
*
|
|
229
|
-
* @param {number|null} count observed test count
|
|
230
|
-
*/
|
|
231
|
-
function formatObservedCount (count) {
|
|
232
|
-
return count === null ? 'an unknown test count' : `${count} observed tests`
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
module.exports = { verifyGeneratedTestStrategy }
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const { environmentNamesEqual } = require('./environment')
|
|
4
|
-
|
|
5
|
-
const ASSIGNMENT_PATTERN =
|
|
6
|
-
/([A-Za-z_][A-Za-z0-9_]*)=(?:"([^"\r\n]*)"|'([^'\r\n]*)'|([^\s]*))(?:[ \t]+|$)/y
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Parses only complete literal environment assignments at the start of a command.
|
|
10
|
-
*
|
|
11
|
-
* @param {string} command command text
|
|
12
|
-
* @returns {{assignments: Array<{name: string, source: string, value: string}>, length: number}} parsed prefix
|
|
13
|
-
*/
|
|
14
|
-
function parseLiteralEnvironmentPrefix (command) {
|
|
15
|
-
const source = command
|
|
16
|
-
const assignments = []
|
|
17
|
-
let offset = 0
|
|
18
|
-
|
|
19
|
-
while (offset < source.length) {
|
|
20
|
-
ASSIGNMENT_PATTERN.lastIndex = offset
|
|
21
|
-
const match = ASSIGNMENT_PATTERN.exec(source)
|
|
22
|
-
if (!match) break
|
|
23
|
-
assignments.push({
|
|
24
|
-
name: match[1],
|
|
25
|
-
source: match[0].trimEnd(),
|
|
26
|
-
value: match[2] ?? match[3] ?? match[4],
|
|
27
|
-
})
|
|
28
|
-
offset = ASSIGNMENT_PATTERN.lastIndex
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
return { assignments, length: offset }
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Removes complete leading assignments that explicitly clear one environment variable.
|
|
36
|
-
*
|
|
37
|
-
* @param {string} command command text
|
|
38
|
-
* @param {string} name environment variable
|
|
39
|
-
* @param {string} [platform] target platform
|
|
40
|
-
*/
|
|
41
|
-
function removeEmptyLiteralEnvironmentAssignments (command, name, platform = process.platform) {
|
|
42
|
-
const source = command
|
|
43
|
-
const prefix = parseLiteralEnvironmentPrefix(source)
|
|
44
|
-
const retained = prefix.assignments.filter(assignment => {
|
|
45
|
-
return !environmentNamesEqual(assignment.name, name, platform) || assignment.value !== ''
|
|
46
|
-
})
|
|
47
|
-
if (retained.length === prefix.assignments.length) return source
|
|
48
|
-
return [...retained.map(assignment => assignment.source), source.slice(prefix.length)]
|
|
49
|
-
.filter(Boolean)
|
|
50
|
-
.join(' ')
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
module.exports = {
|
|
54
|
-
parseLiteralEnvironmentPrefix,
|
|
55
|
-
removeEmptyLiteralEnvironmentAssignments,
|
|
56
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
// Dynamic extglobs, negation, character classes, and malformed braces fail closed.
|
|
4
|
-
function matchesLiteralGlob (filename, pattern) {
|
|
5
|
-
const source = String(pattern || '').replaceAll('\\', '/').replace(/^\.\//, '')
|
|
6
|
-
if (!source || /[!()[\]]/.test(source)) return false
|
|
7
|
-
|
|
8
|
-
let expression = '^'
|
|
9
|
-
for (let index = 0; index < source.length; index++) {
|
|
10
|
-
const character = source[index]
|
|
11
|
-
if (character === '*') {
|
|
12
|
-
if (source[index + 1] === '*') {
|
|
13
|
-
index++
|
|
14
|
-
if (source[index + 1] === '/') {
|
|
15
|
-
index++
|
|
16
|
-
expression += '(?:.*/)?'
|
|
17
|
-
} else {
|
|
18
|
-
expression += '.*'
|
|
19
|
-
}
|
|
20
|
-
} else {
|
|
21
|
-
expression += '[^/]*'
|
|
22
|
-
}
|
|
23
|
-
continue
|
|
24
|
-
}
|
|
25
|
-
if (character === '?') {
|
|
26
|
-
expression += '[^/]'
|
|
27
|
-
continue
|
|
28
|
-
}
|
|
29
|
-
if (character === '{') {
|
|
30
|
-
const end = source.indexOf('}', index + 1)
|
|
31
|
-
if (end === -1) return false
|
|
32
|
-
const alternatives = source.slice(index + 1, end).split(',')
|
|
33
|
-
if (alternatives.length < 2 || alternatives.some(value => !/^[A-Za-z0-9._-]+$/.test(value))) return false
|
|
34
|
-
expression += `(?:${alternatives.map(escapeRegExp).join('|')})`
|
|
35
|
-
// eslint-disable-next-line sonarjs/updated-loop-counter
|
|
36
|
-
index = end
|
|
37
|
-
continue
|
|
38
|
-
}
|
|
39
|
-
expression += escapeRegExp(character)
|
|
40
|
-
}
|
|
41
|
-
try {
|
|
42
|
-
return new RegExp(`${expression}$`).test(String(filename).replaceAll('\\', '/').replaceAll(/^\.\//g, ''))
|
|
43
|
-
} catch {
|
|
44
|
-
return false
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function escapeRegExp (value) {
|
|
49
|
-
return value.replaceAll(/[.*+?^${}()|[\]\\]/g, String.raw`\$&`)
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
module.exports = { matchesLiteralGlob }
|
|
@@ -1,116 +0,0 @@
|
|
|
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 { parseBoundedJson } = require('./bounded-json')
|
|
8
|
-
const { validateManifest } = require('./manifest-schema')
|
|
9
|
-
|
|
10
|
-
const MAX_MANIFEST_BYTES = 5 * 1024 * 1024
|
|
11
|
-
const MAX_MANIFEST_COLLECTION_ENTRIES = 50_000
|
|
12
|
-
const MAX_MANIFEST_ERROR_BYTES = 16 * 1024
|
|
13
|
-
const MAX_MANIFEST_NESTING_DEPTH = 64
|
|
14
|
-
const MAX_MANIFEST_STRING_BYTES = 256 * 1024
|
|
15
|
-
|
|
16
|
-
function loadManifest (manifestPath) {
|
|
17
|
-
const resolvedPath = path.resolve(manifestPath)
|
|
18
|
-
const stat = fs.lstatSync(resolvedPath)
|
|
19
|
-
if (stat.isSymbolicLink() || !stat.isFile()) {
|
|
20
|
-
throw new Error(`Validation manifest must be a regular file, not a symbolic link: ${resolvedPath}`)
|
|
21
|
-
}
|
|
22
|
-
if (stat.size > MAX_MANIFEST_BYTES) {
|
|
23
|
-
throw new Error(`Validation manifest exceeds the ${MAX_MANIFEST_BYTES}-byte size limit: ${resolvedPath}`)
|
|
24
|
-
}
|
|
25
|
-
const raw = fs.readFileSync(resolvedPath)
|
|
26
|
-
const manifest = parseBoundedJson(raw, {
|
|
27
|
-
label: 'Validation manifest JSON',
|
|
28
|
-
maxCollectionEntries: MAX_MANIFEST_COLLECTION_ENTRIES,
|
|
29
|
-
maxNestingDepth: MAX_MANIFEST_NESTING_DEPTH,
|
|
30
|
-
maxStringBytes: MAX_MANIFEST_STRING_BYTES,
|
|
31
|
-
}).value
|
|
32
|
-
|
|
33
|
-
const errors = validateManifest(manifest)
|
|
34
|
-
if (errors.length > 0) {
|
|
35
|
-
throw new Error(`Invalid validation manifest:\n- ${renderErrors(errors)}`)
|
|
36
|
-
}
|
|
37
|
-
manifest.__path = resolvedPath
|
|
38
|
-
Object.defineProperty(manifest, '__sourceSha256', {
|
|
39
|
-
configurable: false,
|
|
40
|
-
enumerable: false,
|
|
41
|
-
value: crypto.createHash('sha256').update(raw).digest('hex'),
|
|
42
|
-
writable: false,
|
|
43
|
-
})
|
|
44
|
-
if (path.dirname(resolvedPath) !== path.resolve(manifest.repository.root)) {
|
|
45
|
-
throw new Error(`Validation manifest must be stored directly in repository.root: ${resolvedPath}`)
|
|
46
|
-
}
|
|
47
|
-
validatePhysicalManifestPaths(manifest)
|
|
48
|
-
|
|
49
|
-
return manifest
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function renderErrors (errors) {
|
|
53
|
-
const rendered = errors.join('\n- ')
|
|
54
|
-
if (Buffer.byteLength(rendered) <= MAX_MANIFEST_ERROR_BYTES) return rendered
|
|
55
|
-
return `${Buffer.from(rendered).subarray(0, MAX_MANIFEST_ERROR_BYTES).toString('utf8')}\n- Additional errors omitted.`
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function validatePhysicalManifestPaths (manifest) {
|
|
59
|
-
const root = fs.realpathSync(manifest.repository.root)
|
|
60
|
-
|
|
61
|
-
for (const [label, candidate] of getManifestPaths(manifest)) {
|
|
62
|
-
if (typeof candidate !== 'string' || !path.isAbsolute(candidate)) continue
|
|
63
|
-
let existing = candidate
|
|
64
|
-
while (!fs.existsSync(existing) && path.dirname(existing) !== existing) existing = path.dirname(existing)
|
|
65
|
-
const physical = fs.realpathSync(existing)
|
|
66
|
-
if (!isPathInside(root, physical)) {
|
|
67
|
-
throw new Error(`Validation manifest ${label} resolves outside repository.root: ${candidate}`)
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function getManifestPaths (manifest) {
|
|
73
|
-
const paths = []
|
|
74
|
-
for (const [frameworkIndex, framework] of (manifest.frameworks || []).entries()) {
|
|
75
|
-
const prefix = `frameworks[${frameworkIndex}]`
|
|
76
|
-
paths.push(
|
|
77
|
-
[`${prefix}.project.root`, framework.project?.root],
|
|
78
|
-
[`${prefix}.project.packageJson`, framework.project?.packageJson],
|
|
79
|
-
[`${prefix}.validation.runner`, framework.validation?.runner],
|
|
80
|
-
[`${prefix}.validation.testFile`, framework.validation?.testFile],
|
|
81
|
-
[`${prefix}.ciWiring.configFile`, framework.ciWiring?.configFile],
|
|
82
|
-
[`${prefix}.ciWiring.workingDirectory`, framework.ciWiring?.workingDirectory]
|
|
83
|
-
)
|
|
84
|
-
for (const [index, fallback] of (framework.validation?.fallbackTests || []).entries()) {
|
|
85
|
-
paths.push([`${prefix}.validation.fallbackTests[${index}].testFile`, fallback.testFile])
|
|
86
|
-
}
|
|
87
|
-
for (const [index, configFile] of (framework.project?.configFiles || []).entries()) {
|
|
88
|
-
paths.push([`${prefix}.project.configFiles[${index}]`, configFile])
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
const strategy = framework.generatedTestStrategy
|
|
92
|
-
paths.push([`${prefix}.generatedTestStrategy.testDirectory`, strategy?.testDirectory])
|
|
93
|
-
for (const [index, file] of (strategy?.files || []).entries()) {
|
|
94
|
-
paths.push([`${prefix}.generatedTestStrategy.files[${index}].path`, file.path])
|
|
95
|
-
}
|
|
96
|
-
for (const [index, cleanupPath] of (strategy?.cleanupPaths || []).entries()) {
|
|
97
|
-
paths.push([`${prefix}.generatedTestStrategy.cleanupPaths[${index}]`, cleanupPath])
|
|
98
|
-
}
|
|
99
|
-
for (const [scenarioIndex, scenario] of (strategy?.scenarios || []).entries()) {
|
|
100
|
-
for (const [identityIndex, identity] of (scenario?.testIdentities || []).entries()) {
|
|
101
|
-
paths.push([
|
|
102
|
-
`${prefix}.generatedTestStrategy.scenarios[${scenarioIndex}].testIdentities[${identityIndex}].file`,
|
|
103
|
-
identity.file,
|
|
104
|
-
])
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
return paths
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
function isPathInside (root, filename) {
|
|
112
|
-
const relative = path.relative(root, filename)
|
|
113
|
-
return relative === '' || (relative && !relative.startsWith('..') && !path.isAbsolute(relative))
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
module.exports = { loadManifest }
|