dd-trace 5.135.0 → 5.136.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,386 +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 { 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
|
-
const { getManifestInputFiles } = require('./runner-command')
|
|
13
|
-
|
|
14
|
-
const APPROVAL_DIGEST_PATTERN = /^[a-f0-9]{64}$/
|
|
15
|
-
const MAX_CAPTURED_PROJECT_SOURCE_BYTES = 512 * 1024
|
|
16
|
-
const OFFLINE_FIXTURE_NONCE_PATTERN = /^[a-f0-9]{32}$/
|
|
17
|
-
const PACKAGE_SNAPSHOT_EXCLUDED_NAMES = new Set(['.git', '.nyc_output', 'node_modules'])
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Binds an approval to the exact manifest bytes and live validator options.
|
|
21
|
-
*
|
|
22
|
-
* @param {object} input approval inputs
|
|
23
|
-
* @param {object} input.manifest loaded manifest
|
|
24
|
-
* @param {string} input.out validation output directory
|
|
25
|
-
* @param {string[]} [input.selectedFrameworkIds] selected framework ids
|
|
26
|
-
* @param {string|null} [input.requestedScenario] selected scenario
|
|
27
|
-
* @param {string} input.offlineFixtureNonce random fixture-root nonce shown in the execution plan
|
|
28
|
-
* @param {boolean} [input.keepTempFiles] whether generated files are retained
|
|
29
|
-
* @param {boolean} [input.verbose] whether command progress is printed
|
|
30
|
-
*/
|
|
31
|
-
function getApprovalDigest ({
|
|
32
|
-
manifest,
|
|
33
|
-
out,
|
|
34
|
-
selectedFrameworkIds = [],
|
|
35
|
-
requestedScenario = null,
|
|
36
|
-
offlineFixtureNonce,
|
|
37
|
-
keepTempFiles = false,
|
|
38
|
-
verbose = false,
|
|
39
|
-
}) {
|
|
40
|
-
const approvalJson = serializeApprovalMaterial({
|
|
41
|
-
manifest,
|
|
42
|
-
out,
|
|
43
|
-
selectedFrameworkIds,
|
|
44
|
-
requestedScenario,
|
|
45
|
-
offlineFixtureNonce,
|
|
46
|
-
keepTempFiles,
|
|
47
|
-
verbose,
|
|
48
|
-
})
|
|
49
|
-
return crypto.createHash('sha256').update(approvalJson).digest('hex')
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Builds the complete, inspectable material covered by one approval fingerprint.
|
|
54
|
-
*
|
|
55
|
-
* Secret-like values are redacted for the artifact while the raw manifest digest still binds their exact bytes.
|
|
56
|
-
*
|
|
57
|
-
* @param {object} input approval inputs
|
|
58
|
-
* @param {object} input.manifest loaded validation manifest
|
|
59
|
-
* @param {string} input.out validation output directory
|
|
60
|
-
* @param {string[]} [input.selectedFrameworkIds] selected framework identifiers
|
|
61
|
-
* @param {string|null} [input.requestedScenario] selected validation scenario
|
|
62
|
-
* @param {string} input.offlineFixtureNonce private offline fixture nonce
|
|
63
|
-
* @param {boolean} [input.keepTempFiles] whether generated files remain after validation
|
|
64
|
-
* @param {boolean} [input.verbose] whether verbose validation output is enabled
|
|
65
|
-
* @returns {object} deterministic approval material
|
|
66
|
-
*/
|
|
67
|
-
function getApprovalMaterial ({
|
|
68
|
-
manifest,
|
|
69
|
-
out,
|
|
70
|
-
selectedFrameworkIds = [],
|
|
71
|
-
requestedScenario = null,
|
|
72
|
-
offlineFixtureNonce,
|
|
73
|
-
keepTempFiles = false,
|
|
74
|
-
verbose = false,
|
|
75
|
-
}) {
|
|
76
|
-
if (!OFFLINE_FIXTURE_NONCE_PATTERN.test(String(offlineFixtureNonce || ''))) {
|
|
77
|
-
throw new Error('Invalid offline fixture nonce. Render a fresh plan with --print-plan.')
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
const validationDirectory = __dirname
|
|
81
|
-
const packageRoot = path.resolve(validationDirectory, '..', '..')
|
|
82
|
-
const packageJsonPath = path.join(packageRoot, 'package.json')
|
|
83
|
-
const packageMetadata = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'))
|
|
84
|
-
const packageFiles = getPackageFiles(packageRoot, [
|
|
85
|
-
manifest.__path,
|
|
86
|
-
out,
|
|
87
|
-
path.join(packageRoot, '.junit-tmp'),
|
|
88
|
-
])
|
|
89
|
-
const includeLocal = requestedScenario !== 'ci-wiring'
|
|
90
|
-
const executableIdentities = includeLocal ? bindManifestExecutables(manifest) : []
|
|
91
|
-
|
|
92
|
-
return {
|
|
93
|
-
schemaVersion: 1,
|
|
94
|
-
sharingWarning: 'Internal diagnostic material. Review repository paths, commands, and CI metadata before sharing.',
|
|
95
|
-
validator: {
|
|
96
|
-
package: packageMetadata.name,
|
|
97
|
-
version: packageMetadata.version,
|
|
98
|
-
packageRoot,
|
|
99
|
-
coveredFiles: packageFiles.map(filename => ({
|
|
100
|
-
path: path.relative(packageRoot, filename).split(path.sep).join('/'),
|
|
101
|
-
sha256: getFileDigest(filename),
|
|
102
|
-
})),
|
|
103
|
-
},
|
|
104
|
-
manifest: {
|
|
105
|
-
path: path.resolve(manifest.__path),
|
|
106
|
-
sha256: getManifestDigest(manifest),
|
|
107
|
-
},
|
|
108
|
-
projectFiles: getApprovalProjectFiles(manifest, { includeLocal }),
|
|
109
|
-
selection: {
|
|
110
|
-
frameworks: [...selectedFrameworkIds],
|
|
111
|
-
scenario: requestedScenario,
|
|
112
|
-
},
|
|
113
|
-
validation: {
|
|
114
|
-
outputDirectory: path.resolve(out),
|
|
115
|
-
offlineFixtureNonce,
|
|
116
|
-
keepTemporaryFiles: keepTempFiles,
|
|
117
|
-
requiredCapabilities: getRequiredCapabilities({
|
|
118
|
-
manifest,
|
|
119
|
-
requestedScenario,
|
|
120
|
-
selectedFrameworkIds,
|
|
121
|
-
}),
|
|
122
|
-
verbose,
|
|
123
|
-
},
|
|
124
|
-
fixtureRecipeDigests: includeLocal
|
|
125
|
-
? getFixtureRecipeDigests({
|
|
126
|
-
frameworks: manifest.frameworks || [],
|
|
127
|
-
selectedFrameworkIds,
|
|
128
|
-
requestedScenario,
|
|
129
|
-
})
|
|
130
|
-
: [],
|
|
131
|
-
commands: getManifestCommands(manifest, requestedScenario)
|
|
132
|
-
.map(([id, command]) => getApprovalCommand(id, command)),
|
|
133
|
-
generatedFiles: getGeneratedFileMaterial(manifest, requestedScenario),
|
|
134
|
-
executables: executableIdentities,
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
// Capability metadata is approval-only; the validator does not request permissions or start prerequisites.
|
|
139
|
-
function getRequiredCapabilities ({ manifest, requestedScenario, selectedFrameworkIds = [] }) {
|
|
140
|
-
if (requestedScenario === 'ci-wiring') return []
|
|
141
|
-
const selected = new Set(selectedFrameworkIds)
|
|
142
|
-
const frameworks = (manifest.frameworks || []).filter(framework => {
|
|
143
|
-
return framework.status === 'runnable' && (selected.size === 0 || selected.has(framework.id))
|
|
144
|
-
})
|
|
145
|
-
const capabilities = new Set()
|
|
146
|
-
if (frameworks.some(framework => ['cypress', 'playwright'].includes(framework.framework) ||
|
|
147
|
-
(framework.framework === 'vitest' && framework.validation?.runnerArgs?.includes('--browser')) ||
|
|
148
|
-
framework.browserRequired === true)) {
|
|
149
|
-
capabilities.add('browser_process')
|
|
150
|
-
}
|
|
151
|
-
if (frameworks.some(framework => framework.localSocketRequired === true ||
|
|
152
|
-
(framework.validation?.fallbackTests || []).some(fallback => fallback.localSocketRequired === true))) {
|
|
153
|
-
capabilities.add('localhost_socket')
|
|
154
|
-
}
|
|
155
|
-
return [...capabilities].sort()
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
function getApprovalProjectFiles (manifest, { includeLocal = true } = {}) {
|
|
159
|
-
return getApprovalProjectSnapshot(manifest, { includeLocal }).projectFiles
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
// Hashes and static-analysis sources come from the same reads to avoid approval-time races.
|
|
163
|
-
function getApprovalProjectSnapshot (manifest, { includeLocal = true } = {}) {
|
|
164
|
-
const projectFiles = []
|
|
165
|
-
const sources = new Map()
|
|
166
|
-
for (const filename of getManifestInputFiles(manifest, { includeLocal })) {
|
|
167
|
-
const stat = fs.lstatSync(filename)
|
|
168
|
-
const contents = fs.readFileSync(filename)
|
|
169
|
-
projectFiles.push({
|
|
170
|
-
path: filename,
|
|
171
|
-
sha256: crypto.createHash('sha256').update(contents).digest('hex'),
|
|
172
|
-
})
|
|
173
|
-
sources.set(
|
|
174
|
-
filename,
|
|
175
|
-
stat.isFile() && !stat.isSymbolicLink() && contents.length <= MAX_CAPTURED_PROJECT_SOURCE_BYTES
|
|
176
|
-
? contents
|
|
177
|
-
: undefined
|
|
178
|
-
)
|
|
179
|
-
}
|
|
180
|
-
return { projectFiles, sources }
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
/**
|
|
184
|
-
* Serializes approval material using stable formatting suitable for independent SHA-256 tools.
|
|
185
|
-
*
|
|
186
|
-
* @param {object} input approval inputs
|
|
187
|
-
*/
|
|
188
|
-
function serializeApprovalMaterial (input) {
|
|
189
|
-
return `${JSON.stringify(getApprovalMaterial(input), null, 2)}\n`
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
/**
|
|
193
|
-
* Returns every regular file owned by the installed dd-trace package.
|
|
194
|
-
*
|
|
195
|
-
* @param {string} packageRoot installed dd-trace package root
|
|
196
|
-
* @param {string[]} excludedPaths generated files or directories outside the package snapshot
|
|
197
|
-
* @returns {string[]} sorted absolute file paths
|
|
198
|
-
*/
|
|
199
|
-
function getPackageFiles (packageRoot, excludedPaths) {
|
|
200
|
-
const files = []
|
|
201
|
-
collectPackageFiles(
|
|
202
|
-
fs.realpathSync(packageRoot),
|
|
203
|
-
excludedPaths.map(resolvePhysicalPath),
|
|
204
|
-
files
|
|
205
|
-
)
|
|
206
|
-
return files.sort()
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
/**
|
|
210
|
-
* Converts one manifest command into its sanitized, execution-relevant approval shape.
|
|
211
|
-
*
|
|
212
|
-
* @param {string} id stable command identifier
|
|
213
|
-
* @param {object} command structured command
|
|
214
|
-
* @returns {object} command approval material
|
|
215
|
-
*/
|
|
216
|
-
function getApprovalCommand (id, command) {
|
|
217
|
-
const shape = {
|
|
218
|
-
id,
|
|
219
|
-
required: command.required !== false,
|
|
220
|
-
usesShell: command.usesShell === true,
|
|
221
|
-
cwd: path.resolve(command.cwd),
|
|
222
|
-
environmentMode: 'clean',
|
|
223
|
-
environment: command.env || {},
|
|
224
|
-
inheritedEnvironmentNames: command.requiredEnvVars || [],
|
|
225
|
-
...getCommandExecutionSettings(command),
|
|
226
|
-
outputPaths: getCommandOutputPaths(command),
|
|
227
|
-
argv: command.argv,
|
|
228
|
-
}
|
|
229
|
-
return sanitizeForReport(shape)
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
/**
|
|
233
|
-
* Returns exact generated test source and cleanup policy covered by the manifest digest.
|
|
234
|
-
*
|
|
235
|
-
* @param {object} manifest loaded manifest
|
|
236
|
-
* @param {string|null} requestedScenario selected validator scenario
|
|
237
|
-
* @returns {object[]} generated file approval material
|
|
238
|
-
*/
|
|
239
|
-
function getGeneratedFileMaterial (manifest, requestedScenario) {
|
|
240
|
-
const files = []
|
|
241
|
-
if (manifest.frameworks) {
|
|
242
|
-
for (const framework of manifest.frameworks) {
|
|
243
|
-
const strategy = framework.generatedTestStrategy
|
|
244
|
-
const selectedPaths = getSelectedGeneratedPaths(strategy, requestedScenario)
|
|
245
|
-
if (strategy?.files) {
|
|
246
|
-
for (const file of strategy.files) {
|
|
247
|
-
if (!selectedPaths.has(path.resolve(file.path))) continue
|
|
248
|
-
const content = `${file.contentLines.join('\n')}\n`
|
|
249
|
-
files.push(sanitizeForReport({
|
|
250
|
-
frameworkId: framework.id,
|
|
251
|
-
path: path.resolve(file.path),
|
|
252
|
-
sha256: crypto.createHash('sha256').update(content).digest('hex'),
|
|
253
|
-
content,
|
|
254
|
-
removeAfterValidation: (strategy.cleanupPaths || []).some(cleanupPath => {
|
|
255
|
-
return path.resolve(cleanupPath) === path.resolve(file.path)
|
|
256
|
-
}),
|
|
257
|
-
}))
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
return files
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
/**
|
|
266
|
-
* Returns generated and support files used by the selected feature.
|
|
267
|
-
*
|
|
268
|
-
* @param {object|undefined} strategy generated strategy
|
|
269
|
-
* @param {string|null} requestedScenario selected validator scenario
|
|
270
|
-
* @returns {Set<string>} selected absolute paths
|
|
271
|
-
*/
|
|
272
|
-
function getSelectedGeneratedPaths (strategy, requestedScenario) {
|
|
273
|
-
if (!strategy || requestedScenario === 'basic-reporting' || requestedScenario === 'ci-wiring') return new Set()
|
|
274
|
-
const generatedId = {
|
|
275
|
-
atr: 'atr-fail-once',
|
|
276
|
-
efd: 'basic-pass',
|
|
277
|
-
'test-management': 'test-management-target',
|
|
278
|
-
}[requestedScenario]
|
|
279
|
-
const scenarioPaths = new Set((strategy.scenarios || []).map(scenario => {
|
|
280
|
-
return path.resolve(scenario.testIdentities[0].file)
|
|
281
|
-
}))
|
|
282
|
-
const selectedPaths = new Set()
|
|
283
|
-
if (strategy.files) {
|
|
284
|
-
for (const file of strategy.files) {
|
|
285
|
-
const filename = path.resolve(file.path)
|
|
286
|
-
if (!requestedScenario || !scenarioPaths.has(filename)) selectedPaths.add(filename)
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
if (generatedId) {
|
|
290
|
-
const scenario = strategy.scenarios?.find(candidate => candidate.id === generatedId)
|
|
291
|
-
if (scenario) selectedPaths.add(path.resolve(scenario.testIdentities[0].file))
|
|
292
|
-
}
|
|
293
|
-
return selectedPaths
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
/**
|
|
297
|
-
* Hashes one covered regular file.
|
|
298
|
-
*
|
|
299
|
-
* @param {string} filename absolute filename
|
|
300
|
-
*/
|
|
301
|
-
function getFileDigest (filename) {
|
|
302
|
-
return crypto.createHash('sha256').update(fs.readFileSync(filename)).digest('hex')
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
/**
|
|
306
|
-
* Collects regular package files without following package-internal symbolic links.
|
|
307
|
-
*
|
|
308
|
-
* @param {string} directory current package directory
|
|
309
|
-
* @param {string[]} excludedPaths generated paths omitted from the package snapshot
|
|
310
|
-
* @param {string[]} files collected files
|
|
311
|
-
*/
|
|
312
|
-
function collectPackageFiles (directory, excludedPaths, files) {
|
|
313
|
-
for (const entry of fs.readdirSync(directory, { withFileTypes: true })) {
|
|
314
|
-
const filename = path.join(directory, entry.name)
|
|
315
|
-
if (PACKAGE_SNAPSHOT_EXCLUDED_NAMES.has(entry.name) || isExcludedPackagePath(filename, excludedPaths)) continue
|
|
316
|
-
if (entry.isDirectory()) {
|
|
317
|
-
collectPackageFiles(filename, excludedPaths, files)
|
|
318
|
-
} else if (entry.isFile()) {
|
|
319
|
-
files.push(filename)
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
/**
|
|
325
|
-
* Checks whether a package path belongs to a generated approval input or output.
|
|
326
|
-
*
|
|
327
|
-
* @param {string} filename package path
|
|
328
|
-
* @param {string[]} excludedPaths generated paths omitted from the package snapshot
|
|
329
|
-
*/
|
|
330
|
-
function isExcludedPackagePath (filename, excludedPaths) {
|
|
331
|
-
return excludedPaths.some(excluded => filename === excluded || filename.startsWith(`${excluded}${path.sep}`))
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
/**
|
|
335
|
-
* Resolves an existing path or its nearest existing ancestor through filesystem aliases.
|
|
336
|
-
*
|
|
337
|
-
* @param {string} filename path that may not exist yet
|
|
338
|
-
*/
|
|
339
|
-
function resolvePhysicalPath (filename) {
|
|
340
|
-
const missingSegments = []
|
|
341
|
-
let existingPath = path.resolve(filename)
|
|
342
|
-
while (!fs.existsSync(existingPath)) {
|
|
343
|
-
missingSegments.unshift(path.basename(existingPath))
|
|
344
|
-
const parent = path.dirname(existingPath)
|
|
345
|
-
if (parent === existingPath) return path.resolve(filename)
|
|
346
|
-
existingPath = parent
|
|
347
|
-
}
|
|
348
|
-
return path.join(fs.realpathSync(existingPath), ...missingSegments)
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
/**
|
|
352
|
-
* Validates an approval digest before live validation executes project code.
|
|
353
|
-
*
|
|
354
|
-
* @param {string | undefined} digest supplied approval digest
|
|
355
|
-
* @param {object} input approval inputs
|
|
356
|
-
*/
|
|
357
|
-
function assertApprovalDigest (digest, input) {
|
|
358
|
-
if (!APPROVAL_DIGEST_PATTERN.test(digest || '')) {
|
|
359
|
-
throw new Error('Invalid approved plan SHA-256. Render a fresh plan with --print-plan.')
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
const expected = getApprovalDigest(input)
|
|
363
|
-
if (digest !== expected) {
|
|
364
|
-
throw new Error(
|
|
365
|
-
'The validation manifest or execution options changed after approval. ' +
|
|
366
|
-
'Render a fresh plan with --print-plan and approve that exact plan before live validation.'
|
|
367
|
-
)
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
function getManifestDigest (manifest) {
|
|
372
|
-
if (manifest.__sourceSha256) return manifest.__sourceSha256
|
|
373
|
-
|
|
374
|
-
const serializable = { ...manifest }
|
|
375
|
-
delete serializable.__path
|
|
376
|
-
return crypto.createHash('sha256').update(JSON.stringify(serializable)).digest('hex')
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
module.exports = {
|
|
380
|
-
assertApprovalDigest,
|
|
381
|
-
getApprovalDigest,
|
|
382
|
-
getApprovalMaterial,
|
|
383
|
-
getApprovalProjectSnapshot,
|
|
384
|
-
getRequiredCapabilities,
|
|
385
|
-
serializeApprovalMaterial,
|
|
386
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
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} source original identifier
|
|
11
|
-
*/
|
|
12
|
-
function getArtifactId (source) {
|
|
13
|
-
const prefix = source.replaceAll(/[^a-zA-Z0-9._-]+/g, '-').slice(0, MAX_PREFIX_LENGTH) || 'framework'
|
|
14
|
-
const digest = crypto.createHash('sha256').update(source).digest('hex').slice(0, 12)
|
|
15
|
-
return `${prefix}-${digest}`
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
module.exports = { getArtifactId }
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const BLOCKER_CATEGORIES = Object.freeze({
|
|
4
|
-
CLEAN_TEST_FAILED: 'CLEAN_TEST_FAILED',
|
|
5
|
-
EXECUTION_ENVIRONMENT_BLOCKED: 'EXECUTION_ENVIRONMENT_BLOCKED',
|
|
6
|
-
PROJECT_SETUP_REQUIRED: 'PROJECT_SETUP_REQUIRED',
|
|
7
|
-
UNSUPPORTED_VERSION: 'UNSUPPORTED_VERSION',
|
|
8
|
-
VALIDATOR_LIMITATION: 'VALIDATOR_LIMITATION',
|
|
9
|
-
})
|
|
10
|
-
|
|
11
|
-
const BLOCKER_CATEGORY_VALUES = new Set(Object.values(BLOCKER_CATEGORIES))
|
|
12
|
-
|
|
13
|
-
function getBlockerDomain (category) {
|
|
14
|
-
const domains = {
|
|
15
|
-
[BLOCKER_CATEGORIES.CLEAN_TEST_FAILED]: 'local_runtime',
|
|
16
|
-
[BLOCKER_CATEGORIES.EXECUTION_ENVIRONMENT_BLOCKED]: 'execution_environment',
|
|
17
|
-
[BLOCKER_CATEGORIES.PROJECT_SETUP_REQUIRED]: 'project_setup',
|
|
18
|
-
[BLOCKER_CATEGORIES.UNSUPPORTED_VERSION]: 'unsupported_version',
|
|
19
|
-
[BLOCKER_CATEGORIES.VALIDATOR_LIMITATION]: 'validator_adapter',
|
|
20
|
-
}
|
|
21
|
-
return domains[category]
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
module.exports = { BLOCKER_CATEGORIES, BLOCKER_CATEGORY_VALUES, getBlockerDomain }
|
|
@@ -1,120 +0,0 @@
|
|
|
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
|
-
*/
|
|
39
|
-
function scanJson (buffer, limits) {
|
|
40
|
-
const containerTypes = new Uint8Array(limits.maxNestingDepth)
|
|
41
|
-
const arrayHasEntry = new Uint8Array(limits.maxNestingDepth)
|
|
42
|
-
let collectionEntries = 0
|
|
43
|
-
let depth = 0
|
|
44
|
-
let escaped = false
|
|
45
|
-
let inString = false
|
|
46
|
-
let stringBytes = 0
|
|
47
|
-
|
|
48
|
-
for (const byte of buffer) {
|
|
49
|
-
if (inString) {
|
|
50
|
-
stringBytes++
|
|
51
|
-
if (stringBytes > limits.maxStringBytes) {
|
|
52
|
-
throw new Error(`${limits.label} contains a string larger than ${limits.maxStringBytes} bytes.`)
|
|
53
|
-
}
|
|
54
|
-
if (escaped) {
|
|
55
|
-
escaped = false
|
|
56
|
-
} else if (byte === 0x5C) {
|
|
57
|
-
escaped = true
|
|
58
|
-
} else if (byte === 0x22) {
|
|
59
|
-
inString = false
|
|
60
|
-
}
|
|
61
|
-
continue
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
if (byte === 0x22) {
|
|
65
|
-
inString = true
|
|
66
|
-
stringBytes = 0
|
|
67
|
-
markArrayEntry()
|
|
68
|
-
continue
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
const containerIndex = depth - 1
|
|
72
|
-
if (containerIndex >= 0 && containerTypes[containerIndex] === 1 &&
|
|
73
|
-
arrayHasEntry[containerIndex] === 0 && !isJsonWhitespace(byte) && byte !== 0x5D) {
|
|
74
|
-
arrayHasEntry[containerIndex] = 1
|
|
75
|
-
addEntry()
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
if (byte === 0x5B || byte === 0x7B) {
|
|
79
|
-
if (depth >= limits.maxNestingDepth) {
|
|
80
|
-
throw new Error(`${limits.label} nesting exceeds ${limits.maxNestingDepth}.`)
|
|
81
|
-
}
|
|
82
|
-
containerTypes[depth] = byte === 0x5B ? 1 : 2
|
|
83
|
-
arrayHasEntry[depth] = 0
|
|
84
|
-
depth++
|
|
85
|
-
} else if (byte === 0x5D || byte === 0x7D) {
|
|
86
|
-
if (depth > 0) depth--
|
|
87
|
-
} else if (byte === 0x2C && containerIndex >= 0 && containerTypes[containerIndex] === 1) {
|
|
88
|
-
arrayHasEntry[containerIndex] = 0
|
|
89
|
-
} else if (byte === 0x3A && containerIndex >= 0 && containerTypes[containerIndex] === 2) {
|
|
90
|
-
addEntry()
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
return collectionEntries
|
|
95
|
-
|
|
96
|
-
function markArrayEntry () {
|
|
97
|
-
const index = depth - 1
|
|
98
|
-
if (index < 0 || containerTypes[index] !== 1 || arrayHasEntry[index] !== 0) return
|
|
99
|
-
arrayHasEntry[index] = 1
|
|
100
|
-
addEntry()
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
function addEntry () {
|
|
104
|
-
collectionEntries++
|
|
105
|
-
if (collectionEntries > limits.maxCollectionEntries) {
|
|
106
|
-
throw new Error(`${limits.label} exceeds ${limits.maxCollectionEntries} aggregate collection entries.`)
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
function isJsonWhitespace (byte) {
|
|
112
|
-
return byte === 0x20 || byte === 0x09 || byte === 0x0A || byte === 0x0D
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
module.exports = {
|
|
116
|
-
DEFAULT_MAX_COLLECTION_ENTRIES,
|
|
117
|
-
DEFAULT_MAX_NESTING_DEPTH,
|
|
118
|
-
DEFAULT_MAX_STRING_BYTES,
|
|
119
|
-
parseBoundedJson,
|
|
120
|
-
}
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const { sanitizeEnv } = require('./redaction')
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Builds the normalized static CI configuration metadata shared by reports.
|
|
7
|
-
*
|
|
8
|
-
* @param {object} framework manifest framework entry
|
|
9
|
-
* @returns {object|undefined} CI configuration context when available
|
|
10
|
-
*/
|
|
11
|
-
function buildCiCommandCandidate (framework) {
|
|
12
|
-
const ciWiring = framework.ciWiring || {}
|
|
13
|
-
if (Object.keys(ciWiring).length === 0) return
|
|
14
|
-
|
|
15
|
-
return removeUndefined({
|
|
16
|
-
provider: ciWiring.provider,
|
|
17
|
-
configFile: ciWiring.configFile,
|
|
18
|
-
workflow: ciWiring.workflow,
|
|
19
|
-
job: ciWiring.job,
|
|
20
|
-
step: ciWiring.step,
|
|
21
|
-
runner: ciWiring.runner,
|
|
22
|
-
shell: ciWiring.shell,
|
|
23
|
-
command: typeof ciWiring.command === 'string' ? ciWiring.command : undefined,
|
|
24
|
-
cwd: ciWiring.workingDirectory,
|
|
25
|
-
terminalTestCommand: ciWiring.terminalTestCommand,
|
|
26
|
-
whySelected: ciWiring.whySelected || ciWiring.selectionReason || ciWiring.diagnosis,
|
|
27
|
-
initialization: ciWiring.initialization,
|
|
28
|
-
transport: ciWiring.transport,
|
|
29
|
-
env: buildCiEnvSummary(ciWiring),
|
|
30
|
-
packageScriptExpansionChain: getFirstArray(
|
|
31
|
-
ciWiring.packageScriptExpansionChain,
|
|
32
|
-
ciWiring.scriptExpansionChain,
|
|
33
|
-
ciWiring.commandExpansion
|
|
34
|
-
),
|
|
35
|
-
runnerToolChain: getFirstArray(
|
|
36
|
-
ciWiring.wrapperChain,
|
|
37
|
-
ciWiring.runnerToolChain,
|
|
38
|
-
ciWiring.toolChain,
|
|
39
|
-
ciWiring.commandChain
|
|
40
|
-
),
|
|
41
|
-
setupCommandIds: ciWiring.setupCommandIds,
|
|
42
|
-
unresolved: ciWiring.unresolved,
|
|
43
|
-
})
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function buildCiEnvSummary (ciWiring) {
|
|
47
|
-
const summary = removeUndefined({
|
|
48
|
-
workflow: sanitizeEnv(ciWiring.workflowEnv || ciWiring.env?.workflow),
|
|
49
|
-
job: sanitizeEnv(ciWiring.jobEnv || ciWiring.env?.job),
|
|
50
|
-
step: sanitizeEnv(ciWiring.stepEnv || ciWiring.env?.step),
|
|
51
|
-
inherited: sanitizeEnv(ciWiring.inheritedEnv),
|
|
52
|
-
})
|
|
53
|
-
|
|
54
|
-
return Object.keys(summary).length > 0 ? summary : undefined
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function getFirstArray (...values) {
|
|
58
|
-
for (const value of values) {
|
|
59
|
-
if (Array.isArray(value) && value.length > 0) return value.map(formatChainEntry)
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
function formatChainEntry (entry) {
|
|
64
|
-
if (typeof entry === 'string') return entry
|
|
65
|
-
if (!entry || typeof entry !== 'object') return String(entry)
|
|
66
|
-
return entry.source ? `${entry.source}: ${entry.command}` : entry.command
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
function removeUndefined (object) {
|
|
70
|
-
const result = {}
|
|
71
|
-
for (const [key, value] of Object.entries(object)) {
|
|
72
|
-
if (value !== undefined) result[key] = value
|
|
73
|
-
}
|
|
74
|
-
return result
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
module.exports = { buildCiCommandCandidate }
|