@cnc-tools/storm 0.16.0 → 0.18.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/dist/bin/storm.js +54 -40
- package/dist/build-info.js +1 -1
- package/dist/chunks/{chunk-VL7WFTVQ.js → chunk-24UYAK4R.js} +465 -365
- package/dist/chunks/{chunk-DC2CDHNK.js → chunk-2JMWUKH3.js} +2074 -473
- package/dist/chunks/{chunk-FOZWA52V.js → chunk-3VXZONGE.js} +481 -376
- package/dist/chunks/{chunk-ZG3WQ4UF.js → chunk-55O4FCN4.js} +1 -1
- package/dist/chunks/{chunk-CN4EFA5J.js → chunk-72ZFEMAW.js} +1 -1
- package/dist/chunks/chunk-AS37D43E.js +2173 -0
- package/dist/chunks/chunk-CQAY6GLP.js +1260 -0
- package/dist/chunks/chunk-DZLU7BYK.js +340 -0
- package/dist/chunks/{chunk-R7XVBZOY.js → chunk-EEENLQHE.js} +59 -11
- package/dist/chunks/{chunk-TJNFVNKR.js → chunk-EI3XDCEI.js} +1 -1
- package/dist/chunks/{chunk-HVNK3I45.js → chunk-FDUY3BNF.js} +1 -1
- package/dist/chunks/{chunk-FCQUJDA4.js → chunk-GUCCYCIO.js} +4 -189
- package/dist/chunks/{chunk-OIY3DMF2.js → chunk-HBI4LEMH.js} +3 -3
- package/dist/chunks/{chunk-2MAD5NKK.js → chunk-K4MDQPLW.js} +1 -18
- package/dist/chunks/chunk-KK7PAWIZ.js +198 -0
- package/dist/chunks/{chunk-G3PHMXH5.js → chunk-KQ5FXRUD.js} +18 -1
- package/dist/chunks/{chunk-5VXBKPW6.js → chunk-LKXHGGGX.js} +1 -1
- package/dist/chunks/{chunk-P357TZAY.js → chunk-LOGHIUUB.js} +21 -18
- package/dist/chunks/{chunk-CK2GZEPK.js → chunk-OEPFINFT.js} +2 -2
- package/dist/chunks/{chunk-DWEAHX4T.js → chunk-OI4AP6Z7.js} +5 -5
- package/dist/chunks/{chunk-V4IKA3WI.js → chunk-PMBQWVTW.js} +26 -19
- package/dist/chunks/chunk-SZMYIIG2.js +88 -0
- package/dist/chunks/{chunk-5CCP36QQ.js → chunk-TXCOFC7N.js} +1 -1
- package/dist/chunks/{chunk-VUPZH7J2.js → chunk-UXD3TVWM.js} +1 -1
- package/dist/chunks/{chunk-3L52KNQA.js → chunk-WNW2QXQK.js} +8 -8
- package/dist/chunks/{chunk-AWBSONHB.js → chunk-XBDRVFEV.js} +55 -16
- package/dist/chunks/{live-app-WECQOQ4C.js → live-app-UY7BEDUN.js} +17 -13
- package/dist/cli.d.ts +28 -0
- package/dist/cli.js +64 -0
- package/dist/commands/exec/across-sandboxes-outcomes.d.ts +2 -2
- package/dist/commands/exec/across-sandboxes-outcomes.js +3 -3
- package/dist/commands/exec/before-run.d.ts +123 -0
- package/dist/commands/exec/before-run.js +105 -0
- package/dist/commands/exec/command.d.ts +67 -14
- package/dist/commands/exec/command.js +31 -95
- package/dist/commands/exec/driver-plan.d.ts +9 -4
- package/dist/commands/exec/driver-plan.js +8 -8
- package/dist/commands/exec/exec-words.js +1 -1
- package/dist/commands/exec/execute-run.d.ts +39 -0
- package/dist/commands/exec/execute-run.js +325 -0
- package/dist/commands/exec/live-view.d.ts +3 -3
- package/dist/commands/exec/live-view.js +16 -15
- package/dist/commands/exec/metadata.js +1 -1
- package/dist/commands/exec/mint-failed.d.ts +38 -0
- package/dist/commands/exec/mint-failed.js +27 -4
- package/dist/commands/exec/outcomes.d.ts +104 -22
- package/dist/commands/exec/outcomes.js +73 -26
- package/dist/commands/exec/plan-run.d.ts +58 -150
- package/dist/commands/exec/plan-run.js +239 -90
- package/dist/commands/exec/progress.d.ts +10 -6
- package/dist/commands/exec/progress.js +38 -25
- package/dist/commands/exec/run-bin.d.ts +11 -11
- package/dist/commands/exec/run-bin.js +9 -9
- package/dist/commands/exec/run-flags.d.ts +69 -0
- package/dist/commands/exec/run-flags.js +58 -0
- package/dist/commands/exec/run-metadata.js +4 -4
- package/dist/commands/exec/run-summary.d.ts +58 -0
- package/dist/commands/exec/run-summary.js +205 -0
- package/dist/commands/exec/runner-refusals.d.ts +82 -0
- package/dist/commands/exec/runner-refusals.js +71 -0
- package/dist/commands/exec/sandbox-progress.js +3 -0
- package/dist/commands/exec/stopped-outcome.d.ts +12 -0
- package/dist/commands/exec/stopped-outcome.js +77 -0
- package/dist/commands/exec/view.d.ts +20 -11
- package/dist/commands/exec/view.js +103 -47
- package/dist/commands/runs/facts.d.ts +8 -4
- package/dist/commands/runs/facts.js +19 -10
- package/dist/commands/runs/list/command.d.ts +16 -8
- package/dist/commands/runs/list/command.js +10 -10
- package/dist/commands/runs/list/outcomes.d.ts +8 -4
- package/dist/commands/runs/logs/command.js +10 -10
- package/dist/commands/runs/show/command.d.ts +16 -8
- package/dist/commands/runs/show/command.js +31 -29
- package/dist/commands/runs/show/metadata.js +1 -1
- package/dist/commands/runs/show/outcomes.d.ts +8 -4
- package/dist/commands/runs/show/outcomes.js +8 -6
- package/dist/commands/snapshots/access.d.ts +111 -0
- package/dist/commands/snapshots/access.js +96 -0
- package/dist/commands/snapshots/build/command.d.ts +376 -101
- package/dist/commands/snapshots/build/command.js +447 -149
- package/dist/commands/snapshots/build/metadata.d.ts +10 -0
- package/dist/commands/snapshots/build/metadata.js +31 -11
- package/dist/commands/snapshots/build/outcomes.d.ts +242 -47
- package/dist/commands/snapshots/build/outcomes.js +200 -36
- package/dist/commands/snapshots/list/command.d.ts +368 -27
- package/dist/commands/snapshots/list/command.js +298 -68
- package/dist/commands/snapshots/list/metadata.d.ts +16 -0
- package/dist/commands/snapshots/list/metadata.js +29 -6
- package/dist/commands/snapshots/list/outcomes.d.ts +247 -15
- package/dist/commands/snapshots/list/outcomes.js +223 -52
- package/dist/commands/snapshots/metadata.js +1 -1
- package/dist/commands/snapshots/prune/command.d.ts +430 -0
- package/dist/commands/snapshots/prune/command.js +161 -0
- package/dist/commands/snapshots/prune/metadata.d.ts +28 -0
- package/dist/commands/snapshots/prune/metadata.js +39 -0
- package/dist/commands/snapshots/prune/outcomes.d.ts +208 -0
- package/dist/commands/snapshots/prune/outcomes.js +78 -0
- package/dist/commands/suites/list/command.js +17 -17
- package/dist/commands/suites/list/outcomes.js +2 -2
- package/dist/commands/test/command.d.ts +67 -14
- package/dist/commands/test/command.js +49 -252
- package/dist/commands/test/outcomes.d.ts +33 -7
- package/dist/config/check-runner.d.ts +3 -3
- package/dist/config/check-runner.js +8 -7
- package/dist/config/credential-resolver.d.ts +50 -5
- package/dist/config/credential-resolver.js +51 -19
- package/dist/config/credential-settle.d.ts +6 -2
- package/dist/config/credential-settle.js +11 -5
- package/dist/config/index.d.ts +2 -2
- package/dist/config/index.js +1 -1
- package/dist/config/runner.d.ts +5 -5
- package/dist/config/runner.js +1 -1
- package/dist/config/schema.d.ts +2 -2
- package/dist/config/schema.js +1 -1
- package/dist/config-file/define.d.ts +1 -1
- package/dist/config-file/define.js +1 -1
- package/dist/config-file/runner.d.ts +5 -5
- package/dist/config-file/toolchain.d.ts +14 -4
- package/dist/config-file/toolchain.js +43 -7
- package/dist/context.d.ts +10 -6
- package/dist/context.js +8 -6
- package/dist/core/across-sandboxes.d.ts +7 -6
- package/dist/core/across-sandboxes.js +123 -152
- package/dist/core/coordinator.d.ts +166 -0
- package/dist/core/coordinator.js +233 -0
- package/dist/core/events.d.ts +2 -2
- package/dist/core/index.d.ts +4 -2
- package/dist/core/index.js +1 -1
- package/dist/core/outcomes.d.ts +148 -0
- package/dist/core/{sandbox-end.js → outcomes.js} +28 -4
- package/dist/core/resources.d.ts +31 -53
- package/dist/core/resources.js +32 -70
- package/dist/core/run-state.d.ts +7 -1
- package/dist/core/run-state.js +2 -0
- package/dist/core/run.d.ts +32 -236
- package/dist/core/run.js +107 -267
- package/dist/core/state-directory.d.ts +1 -1
- package/dist/core/state-directory.js +2 -2
- package/dist/credential/gateways.d.ts +15 -1
- package/dist/credential/index.d.ts +4 -3
- package/dist/credential/index.js +3 -2
- package/dist/credential/live/vercel-cli-gateway.d.ts +1 -1
- package/dist/credential/live/vercel-cli-gateway.js +1 -1
- package/dist/credential/live/vercel-oidc-token-gateway.d.ts +11 -0
- package/dist/credential/live/vercel-oidc-token-gateway.js +16 -0
- package/dist/credential/source.d.ts +73 -6
- package/dist/credential/source.js +55 -2
- package/dist/extension-commands.d.ts +1 -1
- package/dist/extension-commands.js +2 -2
- package/dist/extensions/testserver/commands/pool/create/command.d.ts +35 -2
- package/dist/extensions/testserver/commands/pool/create/command.js +7 -7
- package/dist/extensions/testserver/commands/pool/create/metadata.js +5 -5
- package/dist/extensions/testserver/commands/pool/create/outcomes.d.ts +17 -1
- package/dist/extensions/testserver/commands/pool/list/command.js +4 -4
- package/dist/extensions/testserver/credential-facts.d.ts +6 -2
- package/dist/extensions/testserver/credential-facts.js +29 -11
- package/dist/extensions/testserver/lifecycle.js +7 -1
- package/dist/extensions/testserver/limit.d.ts +3 -0
- package/dist/extensions/testserver/limit.js +3 -0
- package/dist/extensions/testserver/provision.d.ts +8 -1
- package/dist/extensions/testserver/provision.js +8 -3
- package/dist/extensions/testserver/refusals.d.ts +6 -1
- package/dist/extensions/testserver/refusals.js +16 -1
- package/dist/extensions/testserver/resource.d.ts +1 -1
- package/dist/extensions/testserver/resource.js +1 -1
- package/dist/extensions/testserver/result.d.ts +1 -1
- package/dist/extensions/testserver/result.js +9 -4
- package/dist/planning/driver-file-lists.d.ts +0 -15
- package/dist/planning/driver-file-lists.js +2 -21
- package/dist/planning/plan-only.d.ts +3 -14
- package/dist/planning/plan-only.js +11 -20
- package/dist/planning/run-kind-flags.js +2 -2
- package/dist/planning/run-plan.d.ts +45 -12
- package/dist/planning/run-plan.js +4 -3
- package/dist/planning/suites.d.ts +1 -1
- package/dist/planning/suites.js +2 -2
- package/dist/planning/test-plan.d.ts +9 -0
- package/dist/planning/test-plan.js +9 -0
- package/dist/run-directory/recording.js +3 -3
- package/dist/run-directory/run-record.d.ts +26 -11
- package/dist/run-directory/run-record.js +16 -13
- package/dist/runner/base.js +1 -1
- package/dist/runner/build-snapshots.d.ts +60 -29
- package/dist/runner/build-snapshots.js +136 -29
- package/dist/runner/context.d.ts +15 -7
- package/dist/runner/context.js +19 -6
- package/dist/runner/events.d.ts +16 -10
- package/dist/runner/gateways.d.ts +122 -23
- package/dist/runner/gateways.js +1 -1
- package/dist/runner/gh.d.ts +42 -0
- package/dist/runner/gh.js +58 -0
- package/dist/runner/index.d.ts +13 -8
- package/dist/runner/index.js +12 -6
- package/dist/runner/live/checkout-gateway.js +7 -0
- package/dist/runner/live/gh-output.d.ts +17 -0
- package/dist/runner/live/gh-output.js +37 -0
- package/dist/runner/live/gh-token-gateway.d.ts +13 -0
- package/dist/runner/live/gh-token-gateway.js +51 -0
- package/dist/runner/live/sandbox-errors.d.ts +2 -0
- package/dist/runner/live/sandbox-errors.js +4 -0
- package/dist/runner/live/sandbox-gateway.js +140 -4
- package/dist/runner/live/snapshot-index-gateway.d.ts +12 -0
- package/dist/runner/live/{snapshot-cache-gateway.js → snapshot-index-gateway.js} +11 -11
- package/dist/runner/live/snapshot-records.js +12 -12
- package/dist/runner/local-snapshot-index.d.ts +205 -0
- package/dist/runner/local-snapshot-index.js +210 -0
- package/dist/runner/network-policy.d.ts +6 -6
- package/dist/runner/network-policy.js +7 -7
- package/dist/runner/policy-writes.d.ts +1 -1
- package/dist/runner/policy-writes.js +1 -1
- package/dist/runner/prepare.d.ts +14 -14
- package/dist/runner/prepare.js +20 -11
- package/dist/runner/ready.d.ts +19 -11
- package/dist/runner/ready.js +104 -33
- package/dist/runner/sandboxed-command.d.ts +3 -3
- package/dist/runner/sandboxed-command.js +3 -3
- package/dist/runner/scope.d.ts +15 -8
- package/dist/runner/scope.js +16 -5
- package/dist/runner/secrets.d.ts +41 -18
- package/dist/runner/secrets.js +226 -30
- package/dist/runner/session.d.ts +8 -8
- package/dist/runner/session.js +6 -3
- package/dist/runner/shared-snapshot-entry.d.ts +92 -0
- package/dist/runner/shared-snapshot-entry.js +168 -0
- package/dist/runner/shared-snapshot-list.d.ts +81 -0
- package/dist/runner/shared-snapshot-list.js +155 -0
- package/dist/runner/shared-snapshot-lookup.d.ts +51 -0
- package/dist/runner/shared-snapshot-lookup.js +118 -0
- package/dist/runner/shared-snapshot-prune.d.ts +58 -0
- package/dist/runner/shared-snapshot-prune.js +133 -0
- package/dist/runner/snapshot-build.d.ts +42 -14
- package/dist/runner/snapshot-build.js +79 -47
- package/dist/runner/snapshot-choice.js +2 -1
- package/dist/runner/snapshot-inspect.d.ts +39 -40
- package/dist/runner/snapshot-inspect.js +52 -35
- package/dist/runner/snapshot-key.d.ts +32 -17
- package/dist/runner/snapshot-key.js +43 -18
- package/dist/runner/snapshot-source.d.ts +31 -0
- package/dist/runner/snapshot-source.js +122 -0
- package/dist/runner/steps.d.ts +1 -1
- package/dist/runner/steps.js +1 -1
- package/dist/runner/{recipe-check.d.ts → vercel-sandbox-check.d.ts} +4 -2
- package/dist/runner/{recipe-check.js → vercel-sandbox-check.js} +7 -2
- package/dist/runner/{recipe.d.ts → vercel-sandbox-options.d.ts} +59 -28
- package/dist/runner/{recipe.js → vercel-sandbox-options.js} +128 -84
- package/dist/runner/vercel-sandbox-secrets.d.ts +116 -0
- package/dist/runner/{recipe-secrets.js → vercel-sandbox-secrets.js} +159 -26
- package/dist/sdk/extension/credential-diagnosis.d.ts +3 -1
- package/dist/sdk/extension/credential-diagnosis.js +25 -5
- package/dist/sdk/extension/credential-source.d.ts +20 -3
- package/dist/sdk/extension/credential-source.js +4 -4
- package/dist/sdk/extension/index.d.ts +3 -2
- package/dist/sdk/extension/index.js +2 -1
- package/dist/sdk/extension/resource-definition.d.ts +1 -1
- package/dist/sdk/extension/secret-source.d.ts +1 -1
- package/dist/sdk/extension/secret-source.js +1 -1
- package/dist/sdk/extension/vercel-oidc-facts.d.ts +20 -0
- package/dist/sdk/extension/vercel-oidc-facts.js +20 -0
- package/dist/shared/cleanup.d.ts +3 -3
- package/dist/shared/cleanup.js +15 -5
- package/dist/shared/snapshot-text.d.ts +4 -4
- package/dist/shared/snapshot-text.js +11 -11
- package/dist/time/duration.js +1 -1
- package/package.json +5 -3
- package/skills/overview.md +4 -4
- package/skills/plan-runs.md +1 -1
- package/skills/read-run-output.md +6 -6
- package/dist/application.d.ts +0 -21
- package/dist/application.js +0 -30
- package/dist/chunks/chunk-7EENF73W.js +0 -782
- package/dist/chunks/chunk-Z5PBVG3Y.js +0 -2599
- package/dist/commands/exec/across-sandboxes-run.d.ts +0 -180
- package/dist/commands/exec/across-sandboxes-run.js +0 -339
- package/dist/commands/exec/plan-only.d.ts +0 -10
- package/dist/commands/exec/plan-only.js +0 -45
- package/dist/commands/exec/run-command.d.ts +0 -475
- package/dist/commands/exec/run-command.js +0 -603
- package/dist/commands/exec/run-planned.d.ts +0 -20
- package/dist/commands/exec/run-planned.js +0 -22
- package/dist/commands/exec/sandbox-view.d.ts +0 -19
- package/dist/commands/exec/sandbox-view.js +0 -72
- package/dist/commands/test/plan.d.ts +0 -92
- package/dist/commands/test/plan.js +0 -125
- package/dist/core/sandbox-end.d.ts +0 -64
- package/dist/runner/live/snapshot-cache-gateway.d.ts +0 -12
- package/dist/runner/recipe-secrets.d.ts +0 -67
- package/dist/runner/snapshot-cache.d.ts +0 -148
- package/dist/runner/snapshot-cache.js +0 -126
|
@@ -1,26 +1,27 @@
|
|
|
1
|
-
// The runner
|
|
2
|
-
// each run does on top of it. `
|
|
3
|
-
// `resolveSandboxCountDefault` evaluate the declared scaling rules for a run. Every
|
|
1
|
+
// The Vercel Sandbox runner options, the `runner` key of `storm.config.ts`: what a repository's runner snapshot holds and what
|
|
2
|
+
// each run does on top of it. `checkVercelSandboxOptions` holds the runner's static rules; `resolveVcpus` and
|
|
3
|
+
// `resolveSandboxCountDefault` evaluate the declared scaling rules for a run. Every option value is plain data
|
|
4
4
|
// (no functions), and the module names no resource.
|
|
5
5
|
import { parseKeepTime, parseTtl } from "../time/index.js";
|
|
6
6
|
import { RUN_PAYLOAD_VARIABLE } from "../sdk/run/launcher.js";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
|
|
7
|
+
import { checkSnapshotSource } from "./snapshot-source.js";
|
|
8
|
+
import { describeOptionValue, isRecord, reportUnknownKeys } from "./vercel-sandbox-check.js";
|
|
9
|
+
import { checkCredentials, checkManagedCredentials, checkUnsafeSecretEnvVars, credentialSourceIds, } from "./vercel-sandbox-secrets.js";
|
|
10
|
+
export { credentialSourceIds, };
|
|
10
11
|
/**
|
|
11
12
|
* storm's own limit on the number of runner sandboxes, which `runner.sandboxes.max` can't pass: a guard against a
|
|
12
13
|
* typing mistake that would start hundreds of runner sandboxes, not a claim about what Vercel Sandbox holds.
|
|
13
14
|
*/
|
|
14
15
|
export const MAX_RUNNER_SANDBOXES = 32;
|
|
15
|
-
/** The defaults of a
|
|
16
|
-
export const
|
|
16
|
+
/** The defaults of a runner's optional keys. */
|
|
17
|
+
export const VERCEL_SANDBOX_DEFAULTS = {
|
|
17
18
|
cwd: ".",
|
|
18
19
|
timeout: "60m",
|
|
19
20
|
baseRefs: ["main", "origin/main"],
|
|
20
21
|
region: "iad1",
|
|
21
|
-
|
|
22
|
+
image: "vercel/sandbox/node:al-24",
|
|
22
23
|
};
|
|
23
|
-
const
|
|
24
|
+
const VERCEL_SANDBOX_OPTION_KEYS = new Set([
|
|
24
25
|
"name",
|
|
25
26
|
"snapshot",
|
|
26
27
|
"run",
|
|
@@ -28,70 +29,78 @@ const RECIPE_KEYS = new Set([
|
|
|
28
29
|
"vcpus",
|
|
29
30
|
"env",
|
|
30
31
|
"credentials",
|
|
32
|
+
"managedCredentials",
|
|
31
33
|
"unsafeSecretEnvVars",
|
|
32
34
|
"allowedDomains",
|
|
33
35
|
"timeout",
|
|
34
36
|
"keepSandbox",
|
|
35
37
|
"baseRefs",
|
|
36
38
|
"region",
|
|
37
|
-
"
|
|
39
|
+
"image",
|
|
38
40
|
"sandboxes",
|
|
39
41
|
]);
|
|
40
42
|
const SANDBOXES_KEYS = new Set(["max", "default"]);
|
|
41
43
|
const SANDBOXES_DEFAULT_RULE_KEYS = new Set(["filesPerSandbox", "max"]);
|
|
42
44
|
const VCPUS_RULE_KEYS = new Set(["resource", "option", "per", "min", "max"]);
|
|
43
|
-
const SNAPSHOT_KEYS = new Set(["vcpus", "summary", "toolchains", "prebuild"]);
|
|
45
|
+
const SNAPSHOT_KEYS = new Set(["vcpus", "summary", "source", "toolchains", "prebuild"]);
|
|
44
46
|
const RUN_KEYS = new Set(["install", "build"]);
|
|
45
47
|
const STEP_KEYS = new Set(["label", "script"]);
|
|
46
48
|
const TOOLCHAIN_STEP_KEYS = new Set(["label", "script", "baseFiles"]);
|
|
47
49
|
const NAME_PATTERN = /^[a-z0-9][a-z0-9-]*$/;
|
|
48
|
-
/**
|
|
50
|
+
/** Optional VCR registry host prefix on a fully qualified image reference. */
|
|
51
|
+
const VCR_HOST_PREFIX = "vcr.vercel.com/";
|
|
52
|
+
/** Prefix for Vercel-managed sandbox images (with or without `VCR_HOST_PREFIX`). */
|
|
53
|
+
const MANAGED_IMAGE_PREFIX = "vercel/sandbox/";
|
|
54
|
+
/** Digest suffix on a pinned image reference: `sha256:` followed by 64 lowercase hex characters. */
|
|
55
|
+
const IMAGE_DIGEST_PATTERN = /^sha256:[0-9a-f]{64}$/;
|
|
56
|
+
/** A domain the runner's `allowedDomains` lists: a bare hostname, or one with a leading `*.`. */
|
|
49
57
|
const ALLOWED_DOMAIN_PATTERN = /^(?:\*\.)?(?=.{1,253}$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)+$/;
|
|
50
58
|
/**
|
|
51
|
-
* Checks
|
|
59
|
+
* Checks Vercel Sandbox runner options against their static rules: the keys they may hold and each value's shape.
|
|
60
|
+
* Every value must be plain
|
|
52
61
|
* data; functions are refused with the declared form to use instead. Every problem is reported.
|
|
53
62
|
*/
|
|
54
|
-
export function
|
|
63
|
+
export function checkVercelSandboxOptions(value) {
|
|
55
64
|
const problems = [];
|
|
56
65
|
const report = (path, problem) => problems.push({ path, problem });
|
|
57
66
|
if (!isRecord(value)) {
|
|
58
|
-
report([], `must be an object, not ${
|
|
67
|
+
report([], `must be an object, not ${describeOptionValue(value)}`);
|
|
59
68
|
return { ok: false, problems };
|
|
60
69
|
}
|
|
61
|
-
reportUnknownKeys(value,
|
|
70
|
+
reportUnknownKeys(value, VERCEL_SANDBOX_OPTION_KEYS, [], "a vercelSandbox option key", report);
|
|
62
71
|
const name = value["name"];
|
|
63
72
|
if (typeof name !== "string" || !NAME_PATTERN.test(name))
|
|
64
|
-
report(["name"], `must be lowercase letters, digits and dashes, starting with a letter or digit, not ${
|
|
73
|
+
report(["name"], `must be lowercase letters, digits and dashes, starting with a letter or digit, not ${describeOptionValue(name)}`);
|
|
65
74
|
const snapshot = checkSnapshot(value["snapshot"], report);
|
|
66
75
|
const run = checkRun(value["run"], report);
|
|
67
|
-
const cwd = orDefault(value["cwd"],
|
|
76
|
+
const cwd = orDefault(value["cwd"], VERCEL_SANDBOX_DEFAULTS.cwd);
|
|
68
77
|
if (!isRelativePath(cwd))
|
|
69
|
-
report(["cwd"], `must be a path relative to the repository's root, without "..", not ${
|
|
78
|
+
report(["cwd"], `must be a path relative to the repository's root, without "..", not ${describeOptionValue(cwd)}`);
|
|
70
79
|
const vcpus = checkVcpus(value["vcpus"], report);
|
|
71
80
|
const env = checkEnv(value["env"], report);
|
|
72
81
|
const credentials = checkCredentials(value["credentials"], report);
|
|
82
|
+
const managedCredentials = checkManagedCredentials(value["managedCredentials"], credentials, report);
|
|
73
83
|
const unsafeSecretEnvVars = checkUnsafeSecretEnvVars(value["unsafeSecretEnvVars"], env, credentials, report);
|
|
74
84
|
const allowedDomains = checkAllowedDomains(value["allowedDomains"], report);
|
|
75
|
-
const timeout = orDefault(value["timeout"],
|
|
85
|
+
const timeout = orDefault(value["timeout"], VERCEL_SANDBOX_DEFAULTS.timeout);
|
|
76
86
|
const timeoutMinutes = typeof timeout === "string" ? parseTtl(timeout) : undefined;
|
|
77
87
|
if (timeoutMinutes === undefined)
|
|
78
|
-
report(["timeout"], `must be a whole number of minutes or hours from 10m to 5h, not ${
|
|
88
|
+
report(["timeout"], `must be a whole number of minutes or hours from 10m to 5h, not ${describeOptionValue(timeout)}`);
|
|
79
89
|
const keepSandbox = value["keepSandbox"];
|
|
80
90
|
const keepSandboxMinutes = typeof keepSandbox === "string" ? parseKeepTime(keepSandbox) : undefined;
|
|
81
91
|
if (keepSandbox !== undefined && keepSandboxMinutes === undefined)
|
|
82
|
-
report(["keepSandbox"], `must be 0, or a whole number of minutes or hours up to 5h, not ${
|
|
83
|
-
else if (
|
|
84
|
-
unsafeSecretEnvVars.length > 0
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
92
|
+
report(["keepSandbox"], `must be 0, or a whole number of minutes or hours up to 5h, not ${describeOptionValue(keepSandbox)}`);
|
|
93
|
+
else if (keepSandboxMinutes !== undefined && keepSandboxMinutes > 0) {
|
|
94
|
+
if (unsafeSecretEnvVars !== undefined && unsafeSecretEnvVars.length > 0)
|
|
95
|
+
report(["keepSandbox"], "can't be above 0 when runner.unsafeSecretEnvVars is set: a run that passes secrets into the runner sandbox's environment never keeps its runner sandbox");
|
|
96
|
+
if (managedCredentials !== undefined && managedCredentials.length > 0)
|
|
97
|
+
report(["keepSandbox"], "can't be above 0 when runner.managedCredentials is set: Vercel Sandbox rejects deny-all on a sandbox with managed credentials, so storm cannot fence a kept runner sandbox");
|
|
98
|
+
}
|
|
88
99
|
const baseRefs = checkBaseRefs(value["baseRefs"], report);
|
|
89
|
-
const region = orDefault(value["region"],
|
|
100
|
+
const region = orDefault(value["region"], VERCEL_SANDBOX_DEFAULTS.region);
|
|
90
101
|
if (!isNonEmptyString(region))
|
|
91
|
-
report(["region"], `must be a non-empty string, not ${
|
|
92
|
-
const
|
|
93
|
-
if (!isNonEmptyString(runtime))
|
|
94
|
-
report(["runtime"], `must be a non-empty string, not ${describeRecipeValue(runtime)}`);
|
|
102
|
+
report(["region"], `must be a non-empty string, not ${describeOptionValue(region)}`);
|
|
103
|
+
const image = checkImage(orDefault(value["image"], VERCEL_SANDBOX_DEFAULTS.image), report);
|
|
95
104
|
const sandboxes = checkSandboxes(value["sandboxes"], report);
|
|
96
105
|
if (problems.length > 0 ||
|
|
97
106
|
snapshot === undefined ||
|
|
@@ -99,10 +108,12 @@ export function checkRecipe(value) {
|
|
|
99
108
|
vcpus === undefined ||
|
|
100
109
|
env === undefined ||
|
|
101
110
|
credentials === undefined ||
|
|
111
|
+
managedCredentials === undefined ||
|
|
102
112
|
unsafeSecretEnvVars === undefined ||
|
|
103
113
|
allowedDomains === null ||
|
|
104
114
|
baseRefs === undefined ||
|
|
105
115
|
timeoutMinutes === undefined ||
|
|
116
|
+
image === undefined ||
|
|
106
117
|
sandboxes === false)
|
|
107
118
|
return { ok: false, problems };
|
|
108
119
|
return {
|
|
@@ -115,6 +126,7 @@ export function checkRecipe(value) {
|
|
|
115
126
|
vcpus,
|
|
116
127
|
env,
|
|
117
128
|
credentials,
|
|
129
|
+
managedCredentials,
|
|
118
130
|
unsafeSecretEnvVars,
|
|
119
131
|
...(allowedDomains === undefined ? {} : { allowedDomains }),
|
|
120
132
|
timeout: timeout,
|
|
@@ -122,11 +134,44 @@ export function checkRecipe(value) {
|
|
|
122
134
|
keepSandboxMinutes,
|
|
123
135
|
baseRefs,
|
|
124
136
|
region: region,
|
|
125
|
-
|
|
137
|
+
image,
|
|
126
138
|
...(sandboxes === undefined ? {} : { sandboxes }),
|
|
127
139
|
},
|
|
128
140
|
};
|
|
129
141
|
}
|
|
142
|
+
/**
|
|
143
|
+
* Validates `runner.image`: a non-empty string with no whitespace, either a Vercel-managed image starting with
|
|
144
|
+
* `"vercel/sandbox/"` or `"vcr.vercel.com/vercel/sandbox/"` (with a non-empty suffix) or a custom VCR image reference
|
|
145
|
+
* pinned with `@sha256:<64 hex>`. A reference that names a digest, managed or custom, must name a well-formed one. The
|
|
146
|
+
* rest of the reference's grammar is Vercel Sandbox's to check when the build sandbox starts.
|
|
147
|
+
*/
|
|
148
|
+
function checkImage(value, report) {
|
|
149
|
+
if (!isNonEmptyString(value)) {
|
|
150
|
+
report(["image"], `must be a non-empty string, not ${describeOptionValue(value)}`);
|
|
151
|
+
return undefined;
|
|
152
|
+
}
|
|
153
|
+
if (/\s/.test(value)) {
|
|
154
|
+
report(["image"], `must be an image reference with no whitespace, not ${describeOptionValue(value)}`);
|
|
155
|
+
return undefined;
|
|
156
|
+
}
|
|
157
|
+
const at = value.indexOf("@");
|
|
158
|
+
const name = at === -1 ? value : value.slice(0, at);
|
|
159
|
+
const digest = at === -1 ? undefined : value.slice(at + 1);
|
|
160
|
+
if (digest !== undefined && (name === "" || !IMAGE_DIGEST_PATTERN.test(digest))) {
|
|
161
|
+
report(["image"], `must be "<repository>@sha256:<64 lowercase hex characters>" when it names a digest, not ${describeOptionValue(value)}`);
|
|
162
|
+
return undefined;
|
|
163
|
+
}
|
|
164
|
+
const repo = name.startsWith(VCR_HOST_PREFIX) ? name.slice(VCR_HOST_PREFIX.length) : name;
|
|
165
|
+
if (repo === MANAGED_IMAGE_PREFIX) {
|
|
166
|
+
report(["image"], `must name a Vercel-managed image after "${MANAGED_IMAGE_PREFIX}", not ${describeOptionValue(value)}`);
|
|
167
|
+
return undefined;
|
|
168
|
+
}
|
|
169
|
+
if (digest === undefined && !repo.startsWith(MANAGED_IMAGE_PREFIX)) {
|
|
170
|
+
report(["image"], `must be a Vercel-managed image ("${MANAGED_IMAGE_PREFIX}...") or a digest-pinned custom VCR image ("<repository>@sha256:...") so runner snapshots cannot go stale, not ${describeOptionValue(value)}`);
|
|
171
|
+
return undefined;
|
|
172
|
+
}
|
|
173
|
+
return value;
|
|
174
|
+
}
|
|
130
175
|
function checkVcpus(value, report) {
|
|
131
176
|
if (isPositiveInteger(value))
|
|
132
177
|
return value;
|
|
@@ -135,33 +180,33 @@ function checkVcpus(value, report) {
|
|
|
135
180
|
return undefined;
|
|
136
181
|
}
|
|
137
182
|
if (!isRecord(value)) {
|
|
138
|
-
report(["vcpus"], `must be a positive whole number, or { resource, option, per, min, max }, not ${
|
|
183
|
+
report(["vcpus"], `must be a positive whole number, or { resource, option, per, min, max }, not ${describeOptionValue(value)}`);
|
|
139
184
|
return undefined;
|
|
140
185
|
}
|
|
141
|
-
let ok = reportUnknownKeys(value, VCPUS_RULE_KEYS, ["vcpus"], "a
|
|
186
|
+
let ok = reportUnknownKeys(value, VCPUS_RULE_KEYS, ["vcpus"], "a vercelSandbox vcpus rule key", report);
|
|
142
187
|
const resource = value["resource"];
|
|
143
188
|
if (!isNonEmptyString(resource)) {
|
|
144
|
-
report(["vcpus", "resource"], `must be a non-empty string, not ${
|
|
189
|
+
report(["vcpus", "resource"], `must be a non-empty string, not ${describeOptionValue(resource)}`);
|
|
145
190
|
ok = false;
|
|
146
191
|
}
|
|
147
192
|
const option = value["option"];
|
|
148
193
|
if (!isNonEmptyString(option)) {
|
|
149
|
-
report(["vcpus", "option"], `must be a non-empty string, not ${
|
|
194
|
+
report(["vcpus", "option"], `must be a non-empty string, not ${describeOptionValue(option)}`);
|
|
150
195
|
ok = false;
|
|
151
196
|
}
|
|
152
197
|
const per = value["per"];
|
|
153
198
|
if (!isPositiveInteger(per)) {
|
|
154
|
-
report(["vcpus", "per"], `must be a positive whole number, not ${
|
|
199
|
+
report(["vcpus", "per"], `must be a positive whole number, not ${describeOptionValue(per)}`);
|
|
155
200
|
ok = false;
|
|
156
201
|
}
|
|
157
202
|
const min = value["min"];
|
|
158
203
|
if (!isPositiveInteger(min)) {
|
|
159
|
-
report(["vcpus", "min"], `must be a positive whole number, not ${
|
|
204
|
+
report(["vcpus", "min"], `must be a positive whole number, not ${describeOptionValue(min)}`);
|
|
160
205
|
ok = false;
|
|
161
206
|
}
|
|
162
207
|
const max = value["max"];
|
|
163
208
|
if (!isPositiveInteger(max)) {
|
|
164
|
-
report(["vcpus", "max"], `must be a positive whole number, not ${
|
|
209
|
+
report(["vcpus", "max"], `must be a positive whole number, not ${describeOptionValue(max)}`);
|
|
165
210
|
ok = false;
|
|
166
211
|
}
|
|
167
212
|
else if (isPositiveInteger(min) && max < min) {
|
|
@@ -179,7 +224,7 @@ function checkVcpus(value, report) {
|
|
|
179
224
|
: undefined;
|
|
180
225
|
}
|
|
181
226
|
/**
|
|
182
|
-
* The
|
|
227
|
+
* The runner's `sandboxes`: an object whose `max` is a whole number from 1 to `MAX_RUNNER_SANDBOXES`, and whose
|
|
183
228
|
* optional `default` is a whole number from 1 to `MAX_RUNNER_SANDBOXES` or a declared `{ filesPerSandbox, max? }` rule;
|
|
184
229
|
* undefined when absent, and false when it is wrong, which is reported.
|
|
185
230
|
*/
|
|
@@ -187,13 +232,13 @@ function checkSandboxes(value, report) {
|
|
|
187
232
|
if (value === undefined)
|
|
188
233
|
return undefined;
|
|
189
234
|
if (!isRecord(value)) {
|
|
190
|
-
report(["sandboxes"], `must be an object with max, not ${
|
|
235
|
+
report(["sandboxes"], `must be an object with max, not ${describeOptionValue(value)}`);
|
|
191
236
|
return false;
|
|
192
237
|
}
|
|
193
|
-
let ok = reportUnknownKeys(value, SANDBOXES_KEYS, ["sandboxes"], "a
|
|
238
|
+
let ok = reportUnknownKeys(value, SANDBOXES_KEYS, ["sandboxes"], "a vercelSandbox sandboxes key", report);
|
|
194
239
|
const max = value["max"];
|
|
195
240
|
if (!isPositiveInteger(max) || max > MAX_RUNNER_SANDBOXES) {
|
|
196
|
-
report(["sandboxes", "max"], `must be a whole number from 1 to ${MAX_RUNNER_SANDBOXES}, not ${
|
|
241
|
+
report(["sandboxes", "max"], `must be a whole number from 1 to ${MAX_RUNNER_SANDBOXES}, not ${describeOptionValue(max)}`);
|
|
197
242
|
ok = false;
|
|
198
243
|
}
|
|
199
244
|
const rawDefault = value["default"];
|
|
@@ -220,18 +265,18 @@ function checkSandboxesDefault(value, report) {
|
|
|
220
265
|
return undefined;
|
|
221
266
|
}
|
|
222
267
|
if (!isRecord(value)) {
|
|
223
|
-
report(["sandboxes", "default"], `must be a whole number from 1 to ${MAX_RUNNER_SANDBOXES}, or { filesPerSandbox, max? }, not ${
|
|
268
|
+
report(["sandboxes", "default"], `must be a whole number from 1 to ${MAX_RUNNER_SANDBOXES}, or { filesPerSandbox, max? }, not ${describeOptionValue(value)}`);
|
|
224
269
|
return undefined;
|
|
225
270
|
}
|
|
226
|
-
let ok = reportUnknownKeys(value, SANDBOXES_DEFAULT_RULE_KEYS, ["sandboxes", "default"], "a
|
|
271
|
+
let ok = reportUnknownKeys(value, SANDBOXES_DEFAULT_RULE_KEYS, ["sandboxes", "default"], "a vercelSandbox sandboxes default rule key", report);
|
|
227
272
|
const filesPerSandbox = value["filesPerSandbox"];
|
|
228
273
|
if (!isPositiveInteger(filesPerSandbox)) {
|
|
229
|
-
report(["sandboxes", "default", "filesPerSandbox"], `must be a positive whole number, not ${
|
|
274
|
+
report(["sandboxes", "default", "filesPerSandbox"], `must be a positive whole number, not ${describeOptionValue(filesPerSandbox)}`);
|
|
230
275
|
ok = false;
|
|
231
276
|
}
|
|
232
277
|
const max = value["max"];
|
|
233
278
|
if (max !== undefined && (!isPositiveInteger(max) || max > MAX_RUNNER_SANDBOXES)) {
|
|
234
|
-
report(["sandboxes", "default", "max"], `must be a whole number from 1 to ${MAX_RUNNER_SANDBOXES}, not ${
|
|
279
|
+
report(["sandboxes", "default", "max"], `must be a whole number from 1 to ${MAX_RUNNER_SANDBOXES}, not ${describeOptionValue(max)}`);
|
|
235
280
|
ok = false;
|
|
236
281
|
}
|
|
237
282
|
if (!ok)
|
|
@@ -243,37 +288,39 @@ function checkSandboxesDefault(value, report) {
|
|
|
243
288
|
}
|
|
244
289
|
function checkSnapshot(value, report) {
|
|
245
290
|
if (!isRecord(value)) {
|
|
246
|
-
report(["snapshot"], `must be an object of vcpus, toolchains, prebuild, and an optional summary, not ${
|
|
291
|
+
report(["snapshot"], `must be an object of vcpus, toolchains, prebuild, and an optional summary, not ${describeOptionValue(value)}`);
|
|
247
292
|
return undefined;
|
|
248
293
|
}
|
|
249
|
-
let ok = reportUnknownKeys(value, SNAPSHOT_KEYS, ["snapshot"], "a
|
|
294
|
+
let ok = reportUnknownKeys(value, SNAPSHOT_KEYS, ["snapshot"], "a vercelSandbox snapshot key", report);
|
|
250
295
|
const vcpus = value["vcpus"];
|
|
251
296
|
if (!isPositiveInteger(vcpus)) {
|
|
252
|
-
report(["snapshot", "vcpus"], `must be a positive whole number, not ${
|
|
297
|
+
report(["snapshot", "vcpus"], `must be a positive whole number, not ${describeOptionValue(vcpus)}`);
|
|
253
298
|
ok = false;
|
|
254
299
|
}
|
|
255
300
|
const summary = value["summary"];
|
|
256
301
|
if (summary !== undefined && !isNonEmptyString(summary)) {
|
|
257
|
-
report(["snapshot", "summary"], `must be a non-empty string, not ${
|
|
302
|
+
report(["snapshot", "summary"], `must be a non-empty string, not ${describeOptionValue(summary)}`);
|
|
258
303
|
ok = false;
|
|
259
304
|
}
|
|
305
|
+
const source = checkSnapshotSource(value["source"], report);
|
|
260
306
|
const toolchains = checkSteps(value["toolchains"], ["snapshot", "toolchains"], true, report);
|
|
261
307
|
const prebuild = checkSteps(value["prebuild"], ["snapshot", "prebuild"], false, report);
|
|
262
|
-
if (!ok || toolchains === undefined || prebuild === undefined)
|
|
308
|
+
if (!ok || source === false || toolchains === undefined || prebuild === undefined)
|
|
263
309
|
return undefined;
|
|
264
310
|
return {
|
|
265
311
|
vcpus: vcpus,
|
|
266
312
|
...(summary === undefined ? {} : { summary: summary }),
|
|
313
|
+
...(source === undefined ? {} : { source }),
|
|
267
314
|
toolchains,
|
|
268
315
|
prebuild,
|
|
269
316
|
};
|
|
270
317
|
}
|
|
271
318
|
function checkRun(value, report) {
|
|
272
319
|
if (!isRecord(value)) {
|
|
273
|
-
report(["run"], `must be an object of install and build steps, not ${
|
|
320
|
+
report(["run"], `must be an object of install and build steps, not ${describeOptionValue(value)}`);
|
|
274
321
|
return undefined;
|
|
275
322
|
}
|
|
276
|
-
const ok = reportUnknownKeys(value, RUN_KEYS, ["run"], "a
|
|
323
|
+
const ok = reportUnknownKeys(value, RUN_KEYS, ["run"], "a vercelSandbox run key", report);
|
|
277
324
|
const install = checkStep(value["install"], ["run", "install"], false, report);
|
|
278
325
|
const build = checkStep(value["build"], ["run", "build"], false, report);
|
|
279
326
|
return ok && install !== undefined && build !== undefined ? { install, build } : undefined;
|
|
@@ -286,7 +333,7 @@ function checkSteps(value, path, allowBaseFiles, report) {
|
|
|
286
333
|
return undefined;
|
|
287
334
|
}
|
|
288
335
|
if (!Array.isArray(value)) {
|
|
289
|
-
report(path, `must be a list of steps, not ${
|
|
336
|
+
report(path, `must be a list of steps, not ${describeOptionValue(value)}`);
|
|
290
337
|
return undefined;
|
|
291
338
|
}
|
|
292
339
|
const steps = value.map((step, index) => allowBaseFiles
|
|
@@ -297,7 +344,7 @@ function checkSteps(value, path, allowBaseFiles, report) {
|
|
|
297
344
|
function checkStep(value, path, allowBaseFiles, report) {
|
|
298
345
|
if (!isRecord(value)) {
|
|
299
346
|
const shape = allowBaseFiles ? "{ label, script, baseFiles? }" : "{ label, script }";
|
|
300
|
-
report(path, `must be a step, ${shape}, not ${
|
|
347
|
+
report(path, `must be a step, ${shape}, not ${describeOptionValue(value)}`);
|
|
301
348
|
return undefined;
|
|
302
349
|
}
|
|
303
350
|
const allowedKeys = allowBaseFiles ? TOOLCHAIN_STEP_KEYS : STEP_KEYS;
|
|
@@ -306,7 +353,7 @@ function checkStep(value, path, allowBaseFiles, report) {
|
|
|
306
353
|
if (allowedKeys.has(key))
|
|
307
354
|
continue;
|
|
308
355
|
report([...path, key], key === "secrets"
|
|
309
|
-
? "is not a step key: every
|
|
356
|
+
? "is not a step key: every step of the runner gets every credential runner.credentials declares"
|
|
310
357
|
: key === "baseFiles"
|
|
311
358
|
? "is only allowed on snapshot.toolchains steps: this step already sees the base's files"
|
|
312
359
|
: "is not a step key");
|
|
@@ -315,11 +362,11 @@ function checkStep(value, path, allowBaseFiles, report) {
|
|
|
315
362
|
const label = value["label"];
|
|
316
363
|
const script = value["script"];
|
|
317
364
|
if (!isNonEmptyString(label)) {
|
|
318
|
-
report([...path, "label"], `must be a non-empty string, not ${
|
|
365
|
+
report([...path, "label"], `must be a non-empty string, not ${describeOptionValue(label)}`);
|
|
319
366
|
ok = false;
|
|
320
367
|
}
|
|
321
368
|
if (!isNonEmptyString(script)) {
|
|
322
|
-
report([...path, "script"], `must be a non-empty string, not ${
|
|
369
|
+
report([...path, "script"], `must be a non-empty string, not ${describeOptionValue(script)}`);
|
|
323
370
|
ok = false;
|
|
324
371
|
}
|
|
325
372
|
if (!allowBaseFiles)
|
|
@@ -339,7 +386,7 @@ function checkBaseFiles(value, path, report) {
|
|
|
339
386
|
if (value === undefined)
|
|
340
387
|
return undefined;
|
|
341
388
|
if (!Array.isArray(value)) {
|
|
342
|
-
report(path, `must be a list of relative file paths, not ${
|
|
389
|
+
report(path, `must be a list of relative file paths, not ${describeOptionValue(value)}`);
|
|
343
390
|
return null;
|
|
344
391
|
}
|
|
345
392
|
let ok = true;
|
|
@@ -348,7 +395,7 @@ function checkBaseFiles(value, path, report) {
|
|
|
348
395
|
value.forEach((entry, index) => {
|
|
349
396
|
const at = [...path, String(index)];
|
|
350
397
|
if (!isRelativeFilePath(entry)) {
|
|
351
|
-
report(at, `must be a relative file path without leading "/", "./", "..", or trailing "/", not ${
|
|
398
|
+
report(at, `must be a relative file path without leading "/", "./", "..", or trailing "/", not ${describeOptionValue(entry)}`);
|
|
352
399
|
ok = false;
|
|
353
400
|
}
|
|
354
401
|
else if (seen.has(entry)) {
|
|
@@ -366,7 +413,7 @@ function checkEnv(value, report) {
|
|
|
366
413
|
if (value === undefined)
|
|
367
414
|
return {};
|
|
368
415
|
if (!isRecord(value)) {
|
|
369
|
-
report(["env"], `must be an object of strings, not ${
|
|
416
|
+
report(["env"], `must be an object of strings, not ${describeOptionValue(value)}`);
|
|
370
417
|
return undefined;
|
|
371
418
|
}
|
|
372
419
|
let ok = true;
|
|
@@ -377,7 +424,7 @@ function checkEnv(value, report) {
|
|
|
377
424
|
ok = false;
|
|
378
425
|
}
|
|
379
426
|
else if (typeof variable !== "string") {
|
|
380
|
-
report(["env", key], `must be a string, not ${
|
|
427
|
+
report(["env", key], `must be a string, not ${describeOptionValue(variable)}`);
|
|
381
428
|
ok = false;
|
|
382
429
|
}
|
|
383
430
|
else
|
|
@@ -386,14 +433,14 @@ function checkEnv(value, report) {
|
|
|
386
433
|
return ok ? env : undefined;
|
|
387
434
|
}
|
|
388
435
|
/**
|
|
389
|
-
* The
|
|
436
|
+
* The runner's `allowedDomains`: a non-empty list of domains (`ALLOWED_DOMAIN_PATTERN`), none listed twice; undefined
|
|
390
437
|
* when absent, for full access, and null when it is wrong.
|
|
391
438
|
*/
|
|
392
439
|
function checkAllowedDomains(value, report) {
|
|
393
440
|
if (value === undefined)
|
|
394
441
|
return undefined;
|
|
395
442
|
if (!Array.isArray(value)) {
|
|
396
|
-
report(["allowedDomains"], `must be a list of domains, such as ["registry.npmjs.org", "*.example.com"], not ${
|
|
443
|
+
report(["allowedDomains"], `must be a list of domains, such as ["registry.npmjs.org", "*.example.com"], not ${describeOptionValue(value)}`);
|
|
397
444
|
return null;
|
|
398
445
|
}
|
|
399
446
|
if (value.length === 0) {
|
|
@@ -409,7 +456,7 @@ function checkAllowedDomains(value, report) {
|
|
|
409
456
|
ok = false;
|
|
410
457
|
}
|
|
411
458
|
else if (typeof domain !== "string" || !ALLOWED_DOMAIN_PATTERN.test(domain)) {
|
|
412
|
-
report(at, `must be a hostname, such as example.com, or a wildcard with one leading *., such as *.example.com: lowercase letters, digits, dots, and hyphens, with at least one dot, and no scheme, port, or path, not ${
|
|
459
|
+
report(at, `must be a hostname, such as example.com, or a wildcard with one leading *., such as *.example.com: lowercase letters, digits, dots, and hyphens, with at least one dot, and no scheme, port, or path, not ${describeOptionValue(domain)}`);
|
|
413
460
|
ok = false;
|
|
414
461
|
}
|
|
415
462
|
else if (seen.has(domain)) {
|
|
@@ -423,15 +470,15 @@ function checkAllowedDomains(value, report) {
|
|
|
423
470
|
}
|
|
424
471
|
function checkBaseRefs(value, report) {
|
|
425
472
|
if (value === undefined)
|
|
426
|
-
return [...
|
|
473
|
+
return [...VERCEL_SANDBOX_DEFAULTS.baseRefs];
|
|
427
474
|
if (!Array.isArray(value) || value.length === 0) {
|
|
428
|
-
report(["baseRefs"], `must be a non-empty list of refs, not ${
|
|
475
|
+
report(["baseRefs"], `must be a non-empty list of refs, not ${describeOptionValue(value)}`);
|
|
429
476
|
return undefined;
|
|
430
477
|
}
|
|
431
478
|
let ok = true;
|
|
432
479
|
value.forEach((ref, index) => {
|
|
433
480
|
if (!isNonEmptyString(ref)) {
|
|
434
|
-
report(["baseRefs", String(index)], `must be a non-empty string, not ${
|
|
481
|
+
report(["baseRefs", String(index)], `must be a non-empty string, not ${describeOptionValue(ref)}`);
|
|
435
482
|
ok = false;
|
|
436
483
|
}
|
|
437
484
|
});
|
|
@@ -449,29 +496,29 @@ export function declaredBaseFilePaths(toolchains) {
|
|
|
449
496
|
return [...paths].toSorted((a, b) => (a < b ? -1 : a > b ? 1 : 0));
|
|
450
497
|
}
|
|
451
498
|
/**
|
|
452
|
-
* The runner sandbox's vCPUs for `run`: the
|
|
499
|
+
* The runner sandbox's vCPUs for `run`: the runner's number, or the declared resource-scaling rule evaluated against
|
|
453
500
|
* `run.resources` and `run.sandboxes`. When the named resource is absent from the run, `min` is used. When the named
|
|
454
501
|
* resource is present and its named option is missing or not a non-negative finite number, returns a problem.
|
|
455
502
|
*/
|
|
456
|
-
export function resolveVcpus(
|
|
457
|
-
if (typeof
|
|
458
|
-
return { ok: true, vcpus:
|
|
459
|
-
const { resource, option, per, min, max } =
|
|
460
|
-
const
|
|
461
|
-
if (
|
|
503
|
+
export function resolveVcpus(options, run) {
|
|
504
|
+
if (typeof options.vcpus === "number")
|
|
505
|
+
return { ok: true, vcpus: options.vcpus };
|
|
506
|
+
const { resource, option, per, min, max } = options.vcpus;
|
|
507
|
+
const resourceOptions = Object.hasOwn(run.resources, resource) ? run.resources[resource] : undefined;
|
|
508
|
+
if (resourceOptions === undefined)
|
|
462
509
|
return { ok: true, vcpus: min };
|
|
463
|
-
const raw = Object.hasOwn(
|
|
510
|
+
const raw = Object.hasOwn(resourceOptions, option) ? resourceOptions[option] : undefined;
|
|
464
511
|
if (typeof raw !== "number" || !Number.isFinite(raw) || raw < 0) {
|
|
465
512
|
return {
|
|
466
513
|
ok: false,
|
|
467
|
-
problem: `resource "${resource}" option "${option}" must be a non-negative number, not ${
|
|
514
|
+
problem: `resource "${resource}" option "${option}" must be a non-negative number, not ${describeOptionValue(raw)}`,
|
|
468
515
|
};
|
|
469
516
|
}
|
|
470
517
|
const perSandbox = Math.ceil(raw / Math.max(1, run.sandboxes));
|
|
471
518
|
return { ok: true, vcpus: Math.min(max, Math.max(min, per * perSandbox)) };
|
|
472
519
|
}
|
|
473
520
|
/**
|
|
474
|
-
* The number of runner sandboxes `runner.sandboxes.default` gives a run with test plan `testPlan`: the
|
|
521
|
+
* The number of runner sandboxes `runner.sandboxes.default` gives a run with test plan `testPlan`: the runner's number,
|
|
475
522
|
* or the declared `{ filesPerSandbox, max? }` rule evaluated against `testPlan`. A number above `sandboxes.max` is not
|
|
476
523
|
* a problem here: the run lowers it to `sandboxes.max` and says so.
|
|
477
524
|
*/
|
|
@@ -487,9 +534,6 @@ export function resolveSandboxCountDefault(sandboxesDefault, testPlan) {
|
|
|
487
534
|
function orDefault(value, fallback) {
|
|
488
535
|
return value === undefined ? fallback : value;
|
|
489
536
|
}
|
|
490
|
-
function isRecord(value) {
|
|
491
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
492
|
-
}
|
|
493
537
|
function isNonEmptyString(value) {
|
|
494
538
|
return typeof value === "string" && value.length > 0;
|
|
495
539
|
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { type SecretSource } from "../sdk/extension/index.ts";
|
|
2
|
+
import { type GhTokenFormat } from "./gh.ts";
|
|
3
|
+
import { type Report } from "./vercel-sandbox-check.ts";
|
|
4
|
+
export type { GhTokenFormat };
|
|
5
|
+
/**
|
|
6
|
+
* A Vercel-managed sandbox credential passed to `Sandbox.create({ credentials })`: Vercel Sandbox resolves the
|
|
7
|
+
* secret from the project's or team's Vercel environment variables and injects it through the Sandbox firewall, so the
|
|
8
|
+
* secret never sits on the launch machine or inside the sandbox.
|
|
9
|
+
*/
|
|
10
|
+
export type ManagedCredential = "npm";
|
|
11
|
+
/**
|
|
12
|
+
* Reads a GitHub credential on the launch machine from `gh auth token --hostname <host>`, or from an optional launcher
|
|
13
|
+
* environment variable `env` when set (such as `GITHUB_TOKEN` in CI). Always produces the `authorization` header
|
|
14
|
+
* (`Basic <base64(x-access-token:<token>)>` or `Bearer <token>`).
|
|
15
|
+
*/
|
|
16
|
+
export interface GhCredentialSource {
|
|
17
|
+
readonly kind: "gh";
|
|
18
|
+
/**
|
|
19
|
+
* Optional launcher environment variable override (such as `GITHUB_TOKEN` in CI). When set and non-empty, storm
|
|
20
|
+
* reads the raw token from it instead of invoking `gh auth token`.
|
|
21
|
+
*/
|
|
22
|
+
readonly env?: string;
|
|
23
|
+
/**
|
|
24
|
+
* GitHub hostname passed to `gh auth token --hostname <host>`. Bare hostname, defaulting to `"github.com"`.
|
|
25
|
+
*/
|
|
26
|
+
readonly host?: string;
|
|
27
|
+
/**
|
|
28
|
+
* How storm frames the token in the `authorization` header: `"basic"` (`Basic <base64(x-access-token:<token>)>`, for
|
|
29
|
+
* Git over HTTPS) or `"bearer"` (`Bearer <token>`, for REST and GraphQL APIs). Defaults to `"basic"` when `domain`
|
|
30
|
+
* matches `host` (such as `"github.com"`), and `"bearer"` otherwise (such as `"api.github.com"`).
|
|
31
|
+
*/
|
|
32
|
+
readonly format?: GhTokenFormat;
|
|
33
|
+
}
|
|
34
|
+
/** Where storm reads a sandbox credential's value on the launch machine (`runner.credentials`). */
|
|
35
|
+
export type SandboxCredentialSource = SecretSource | GhCredentialSource;
|
|
36
|
+
/**
|
|
37
|
+
* One sandbox credential declared in `runner.credentials`: a header the Sandbox firewall adds to a sandbox's requests
|
|
38
|
+
* to one domain while the runner's steps and the command run, with its value read from `source` as the run starts. The
|
|
39
|
+
* value never enters the sandbox.
|
|
40
|
+
*/
|
|
41
|
+
export interface CredentialDeclaration {
|
|
42
|
+
/**
|
|
43
|
+
* A bare hostname, such as `registry.example.com`: lowercase letters, digits, dots, and hyphens, with at least one
|
|
44
|
+
* dot, and no scheme, port, path, or wildcard.
|
|
45
|
+
*/
|
|
46
|
+
readonly domain: string;
|
|
47
|
+
/**
|
|
48
|
+
* The header's name; `authorization` by default. storm matches it case-insensitively and sends it in lowercase. It
|
|
49
|
+
* can't be `host`, `content-length`, `transfer-encoding`, or `connection`, and `{ kind: "gh" }` sources only set
|
|
50
|
+
* `authorization`.
|
|
51
|
+
*/
|
|
52
|
+
readonly header?: string;
|
|
53
|
+
/**
|
|
54
|
+
* Where storm reads the credential on the launch machine: `{ kind: "env", name }` for a launcher environment variable
|
|
55
|
+
* holding the whole header value (such as `Bearer …` or `Basic …`), or `{ kind: "gh", env?, host?, format? }` for
|
|
56
|
+
* `gh auth token` (with an optional CI environment variable override).
|
|
57
|
+
*/
|
|
58
|
+
readonly source: SandboxCredentialSource;
|
|
59
|
+
/**
|
|
60
|
+
* Which requests to `domain` get the header: `read` (the default), `GET` and `HEAD` only, and the firewall answers
|
|
61
|
+
* every other request to `domain` with 403; or `all`, every request.
|
|
62
|
+
*/
|
|
63
|
+
readonly requests?: "read" | "all";
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* One unsafe secret environment variable declared in `runner.unsafeSecretEnvVars`: an environment variable `name`
|
|
67
|
+
* exposed to the command inside the runner sandbox, with its value read from `source` on the launch machine as the run
|
|
68
|
+
* starts.
|
|
69
|
+
*/
|
|
70
|
+
export interface UnsafeSecretEnvVar {
|
|
71
|
+
/**
|
|
72
|
+
* The environment variable name exposed to the command inside the runner sandbox: letters, digits, and underscores,
|
|
73
|
+
* not starting with a digit, and none of `STORM_RUN`, the reserved shell or dynamic-loader variables, or a name set
|
|
74
|
+
* by `runner.env`.
|
|
75
|
+
*/
|
|
76
|
+
readonly name: string;
|
|
77
|
+
/**
|
|
78
|
+
* Where storm reads the value on the launch machine, today `{ kind: "env", name }` for a launcher environment
|
|
79
|
+
* variable. Cannot share a source with any entry in `runner.credentials`.
|
|
80
|
+
*/
|
|
81
|
+
readonly source: SecretSource;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* A stable, value-free identity string for one `SandboxCredentialSource`, for hashing into runner snapshot keys:
|
|
85
|
+
* `"env:<name>"` for `{ kind: "env", name }`, and `"gh[:host=<host>][:env=<NAME>][:format=<format>]"` for
|
|
86
|
+
* `{ kind: "gh" }` (omitting `host` when it is the default `"github.com"`). Never contains secret values or file
|
|
87
|
+
* paths.
|
|
88
|
+
*/
|
|
89
|
+
export declare function sandboxCredentialSourceId(source: SandboxCredentialSource): string;
|
|
90
|
+
/**
|
|
91
|
+
* The sorted, unique sandbox credential source identities checked runner options' credentials and managed credentials
|
|
92
|
+
* read from (such as `"env:NPM_AUTH"`, `"gh"`, or `"managed:npm"`), for hashing into the runner snapshot key.
|
|
93
|
+
*/
|
|
94
|
+
export declare function credentialSourceIds(options: {
|
|
95
|
+
readonly credentials: readonly Required<CredentialDeclaration>[];
|
|
96
|
+
readonly managedCredentials?: readonly ManagedCredential[];
|
|
97
|
+
}): readonly string[];
|
|
98
|
+
/**
|
|
99
|
+
* Validates `runner.managedCredentials`: a list of distinct supported Vercel-managed credential providers (today
|
|
100
|
+
* `"npm"`). Refuses combining `"npm"` with a `runner.credentials` entry setting `authorization` on
|
|
101
|
+
* `registry.npmjs.org`, because a custom domain rule overrides the Vercel-managed npm header.
|
|
102
|
+
*/
|
|
103
|
+
export declare function checkManagedCredentials(value: unknown, credentials: readonly Required<CredentialDeclaration>[] | undefined, report: Report): readonly ManagedCredential[] | undefined;
|
|
104
|
+
/**
|
|
105
|
+
* The sandbox credentials: a list of `{ domain, header?, source, requests? }` (`checkCredential`), with no two going
|
|
106
|
+
* to the same domain and header, since the firewall sets each header once on a domain, and no two for one domain that
|
|
107
|
+
* differ in `requests`, since the firewall has one rule set per domain. One `source` may serve several domains. The
|
|
108
|
+
* checked list holds each header in lowercase and each `requests` given.
|
|
109
|
+
*/
|
|
110
|
+
export declare function checkCredentials(value: unknown, report: Report): readonly Required<CredentialDeclaration>[] | undefined;
|
|
111
|
+
/**
|
|
112
|
+
* The runner's `unsafeSecretEnvVars`: a list of `{ name, source }` plain objects, each exposing a distinct environment
|
|
113
|
+
* variable `name` that neither storm sets for the command (`STORM_RUN`, `RESERVED_UNSAFE_SECRET_ENV_VAR_NAMES`,
|
|
114
|
+
* `LD_*`, `DYLD_*`) nor `runner.env` sets, read from a `SecretSource` that `runner.credentials` doesn't already read.
|
|
115
|
+
*/
|
|
116
|
+
export declare function checkUnsafeSecretEnvVars(value: unknown, env: Readonly<Record<string, string>> | undefined, credentials: readonly Required<CredentialDeclaration>[] | undefined, report: Report): readonly UnsafeSecretEnvVar[] | undefined;
|