@cnc-tools/storm 0.16.0 → 0.17.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/application.d.ts +22 -13
- package/dist/application.js +21 -10
- package/dist/bin/run.d.ts +18 -0
- package/dist/bin/run.js +31 -0
- package/dist/bin/storm.js +42 -26
- package/dist/build-info.js +1 -1
- package/dist/chunks/{chunk-5CCP36QQ.js → chunk-2RNDPDTJ.js} +2 -2
- package/dist/chunks/chunk-2VP4GRJM.js +1219 -0
- package/dist/chunks/{chunk-P357TZAY.js → chunk-4O5C2XGJ.js} +18 -15
- package/dist/chunks/{chunk-VL7WFTVQ.js → chunk-4WAMTUWZ.js} +419 -340
- package/dist/chunks/{chunk-OIY3DMF2.js → chunk-6UHIJXZG.js} +3 -3
- package/dist/chunks/{chunk-CN4EFA5J.js → chunk-72ZFEMAW.js} +1 -1
- package/dist/chunks/{chunk-CK2GZEPK.js → chunk-7DZE67QM.js} +2 -2
- package/dist/chunks/{chunk-VUPZH7J2.js → chunk-BCBKYOHW.js} +1 -1
- package/dist/chunks/{chunk-2MAD5NKK.js → chunk-CKGZA25H.js} +1 -18
- package/dist/chunks/{chunk-ZG3WQ4UF.js → chunk-D27KILIA.js} +1 -1
- package/dist/chunks/{chunk-V4IKA3WI.js → chunk-DADEYJDW.js} +24 -17
- package/dist/chunks/{chunk-R7XVBZOY.js → chunk-EEENLQHE.js} +59 -11
- package/dist/chunks/chunk-F4MOYHRY.js +198 -0
- package/dist/chunks/{chunk-HVNK3I45.js → chunk-FNBB6V4R.js} +1 -1
- package/dist/chunks/{chunk-G3PHMXH5.js → chunk-GRT3UIBV.js} +18 -1
- package/dist/chunks/chunk-HP3CURSZ.js +88 -0
- package/dist/chunks/{chunk-DWEAHX4T.js → chunk-HWIQ2S7K.js} +5 -5
- package/dist/chunks/chunk-JN3YY6ZH.js +2166 -0
- package/dist/chunks/{chunk-TJNFVNKR.js → chunk-LKTZ5OXS.js} +1 -1
- package/dist/chunks/{chunk-3L52KNQA.js → chunk-M7EKRGVD.js} +8 -8
- package/dist/chunks/chunk-MR77L2GK.js +340 -0
- package/dist/chunks/{chunk-DC2CDHNK.js → chunk-RNAS7JHE.js} +1438 -445
- package/dist/chunks/{chunk-FCQUJDA4.js → chunk-RWIXDDCK.js} +4 -189
- package/dist/chunks/{chunk-5VXBKPW6.js → chunk-WV3DP6NR.js} +1 -1
- package/dist/chunks/{chunk-AWBSONHB.js → chunk-XBDRVFEV.js} +55 -16
- package/dist/chunks/{chunk-FOZWA52V.js → chunk-YEPFSLQR.js} +480 -375
- package/dist/chunks/{live-app-WECQOQ4C.js → live-app-R76JQXZL.js} +15 -13
- package/dist/commands/exec/across-sandboxes-outcomes.d.ts +1 -1
- package/dist/commands/exec/across-sandboxes-outcomes.js +2 -2
- 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 +31 -2
- 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 +34 -8
- package/dist/commands/exec/outcomes.js +30 -23
- package/dist/commands/exec/plan-run.d.ts +58 -150
- package/dist/commands/exec/plan-run.js +232 -88
- 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 +7 -3
- package/dist/commands/runs/facts.js +17 -8
- package/dist/commands/runs/list/command.d.ts +14 -6
- package/dist/commands/runs/list/command.js +10 -10
- package/dist/commands/runs/list/outcomes.d.ts +7 -3
- package/dist/commands/runs/logs/command.js +10 -10
- package/dist/commands/runs/show/command.d.ts +14 -6
- package/dist/commands/runs/show/command.js +30 -28
- package/dist/commands/runs/show/outcomes.d.ts +7 -3
- package/dist/commands/runs/show/outcomes.js +7 -5
- 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 +360 -93
- package/dist/commands/snapshots/build/command.js +446 -150
- 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 +234 -43
- package/dist/commands/snapshots/build/outcomes.js +200 -36
- package/dist/commands/snapshots/list/command.d.ts +366 -25
- package/dist/commands/snapshots/list/command.js +296 -66
- 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 +245 -13
- package/dist/commands/snapshots/list/outcomes.js +221 -50
- 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 +31 -2
- package/dist/commands/test/command.js +49 -252
- package/dist/commands/test/outcomes.d.ts +15 -1
- 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 +1 -1
- package/dist/config-file/toolchain.js +2 -2
- package/dist/context.d.ts +8 -6
- package/dist/context.js +7 -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 +106 -266
- 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 +6 -1
- package/dist/extension-commands.js +15 -1
- 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 +2 -2
- package/dist/run-directory/run-record.d.ts +21 -6
- package/dist/run-directory/run-record.js +12 -9
- package/dist/runner/base.js +1 -1
- package/dist/runner/build-snapshots.d.ts +55 -29
- package/dist/runner/build-snapshots.js +130 -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 +87 -21
- package/dist/runner/gateways.js +1 -1
- package/dist/runner/index.d.ts +11 -7
- package/dist/runner/index.js +9 -4
- 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 +129 -3
- 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 +6 -7
- package/dist/runner/local-snapshot-index.d.ts +199 -0
- package/dist/runner/local-snapshot-index.js +211 -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 +18 -10
- 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 +10 -6
- package/dist/runner/scope.js +10 -3
- package/dist/runner/secrets.d.ts +13 -13
- package/dist/runner/secrets.js +18 -15
- package/dist/runner/session.d.ts +8 -8
- package/dist/runner/session.js +3 -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 +32 -29
- package/dist/runner/snapshot-choice.js +1 -1
- package/dist/runner/snapshot-inspect.d.ts +39 -40
- package/dist/runner/snapshot-inspect.js +55 -35
- package/dist/runner/snapshot-key.d.ts +13 -12
- package/dist/runner/snapshot-key.js +13 -12
- 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} +2 -2
- package/dist/runner/{recipe-check.js → vercel-sandbox-check.js} +3 -2
- package/dist/runner/{recipe.d.ts → vercel-sandbox-options.d.ts} +24 -23
- package/dist/runner/{recipe.js → vercel-sandbox-options.js} +70 -69
- package/dist/runner/{recipe-secrets.d.ts → vercel-sandbox-secrets.d.ts} +6 -6
- package/dist/runner/{recipe-secrets.js → vercel-sandbox-secrets.js} +20 -20
- package/dist/sdk/extension/commands.d.ts +8 -3
- package/dist/sdk/extension/commands.js +3 -1
- 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 +3 -2
- package/skills/overview.md +4 -4
- package/skills/plan-runs.md +1 -1
- package/skills/read-run-output.md +6 -6
- 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/snapshot-cache.d.ts +0 -148
- package/dist/runner/snapshot-cache.js +0 -126
|
@@ -1,26 +1,26 @@
|
|
|
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 { checkCredentials, checkUnsafeSecretEnvVars, credentialSourceIds, } from "./
|
|
7
|
+
import { describeOptionValue, reportUnknownKeys } from "./vercel-sandbox-check.js";
|
|
8
|
+
import { checkCredentials, checkUnsafeSecretEnvVars, credentialSourceIds, } from "./vercel-sandbox-secrets.js";
|
|
9
9
|
export { credentialSourceIds };
|
|
10
10
|
/**
|
|
11
11
|
* storm's own limit on the number of runner sandboxes, which `runner.sandboxes.max` can't pass: a guard against a
|
|
12
12
|
* typing mistake that would start hundreds of runner sandboxes, not a claim about what Vercel Sandbox holds.
|
|
13
13
|
*/
|
|
14
14
|
export const MAX_RUNNER_SANDBOXES = 32;
|
|
15
|
-
/** The defaults of a
|
|
16
|
-
export const
|
|
15
|
+
/** The defaults of a runner's optional keys. */
|
|
16
|
+
export const VERCEL_SANDBOX_DEFAULTS = {
|
|
17
17
|
cwd: ".",
|
|
18
18
|
timeout: "60m",
|
|
19
19
|
baseRefs: ["main", "origin/main"],
|
|
20
20
|
region: "iad1",
|
|
21
21
|
runtime: "node22",
|
|
22
22
|
};
|
|
23
|
-
const
|
|
23
|
+
const VERCEL_SANDBOX_OPTION_KEYS = new Set([
|
|
24
24
|
"name",
|
|
25
25
|
"snapshot",
|
|
26
26
|
"run",
|
|
@@ -45,53 +45,54 @@ const RUN_KEYS = new Set(["install", "build"]);
|
|
|
45
45
|
const STEP_KEYS = new Set(["label", "script"]);
|
|
46
46
|
const TOOLCHAIN_STEP_KEYS = new Set(["label", "script", "baseFiles"]);
|
|
47
47
|
const NAME_PATTERN = /^[a-z0-9][a-z0-9-]*$/;
|
|
48
|
-
/** A domain the
|
|
48
|
+
/** A domain the runner's `allowedDomains` lists: a bare hostname, or one with a leading `*.`. */
|
|
49
49
|
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
50
|
/**
|
|
51
|
-
* Checks
|
|
51
|
+
* Checks Vercel Sandbox runner options against their static rules: the keys they may hold and each value's shape.
|
|
52
|
+
* Every value must be plain
|
|
52
53
|
* data; functions are refused with the declared form to use instead. Every problem is reported.
|
|
53
54
|
*/
|
|
54
|
-
export function
|
|
55
|
+
export function checkVercelSandboxOptions(value) {
|
|
55
56
|
const problems = [];
|
|
56
57
|
const report = (path, problem) => problems.push({ path, problem });
|
|
57
58
|
if (!isRecord(value)) {
|
|
58
|
-
report([], `must be an object, not ${
|
|
59
|
+
report([], `must be an object, not ${describeOptionValue(value)}`);
|
|
59
60
|
return { ok: false, problems };
|
|
60
61
|
}
|
|
61
|
-
reportUnknownKeys(value,
|
|
62
|
+
reportUnknownKeys(value, VERCEL_SANDBOX_OPTION_KEYS, [], "a vercelSandbox option key", report);
|
|
62
63
|
const name = value["name"];
|
|
63
64
|
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 ${
|
|
65
|
+
report(["name"], `must be lowercase letters, digits and dashes, starting with a letter or digit, not ${describeOptionValue(name)}`);
|
|
65
66
|
const snapshot = checkSnapshot(value["snapshot"], report);
|
|
66
67
|
const run = checkRun(value["run"], report);
|
|
67
|
-
const cwd = orDefault(value["cwd"],
|
|
68
|
+
const cwd = orDefault(value["cwd"], VERCEL_SANDBOX_DEFAULTS.cwd);
|
|
68
69
|
if (!isRelativePath(cwd))
|
|
69
|
-
report(["cwd"], `must be a path relative to the repository's root, without "..", not ${
|
|
70
|
+
report(["cwd"], `must be a path relative to the repository's root, without "..", not ${describeOptionValue(cwd)}`);
|
|
70
71
|
const vcpus = checkVcpus(value["vcpus"], report);
|
|
71
72
|
const env = checkEnv(value["env"], report);
|
|
72
73
|
const credentials = checkCredentials(value["credentials"], report);
|
|
73
74
|
const unsafeSecretEnvVars = checkUnsafeSecretEnvVars(value["unsafeSecretEnvVars"], env, credentials, report);
|
|
74
75
|
const allowedDomains = checkAllowedDomains(value["allowedDomains"], report);
|
|
75
|
-
const timeout = orDefault(value["timeout"],
|
|
76
|
+
const timeout = orDefault(value["timeout"], VERCEL_SANDBOX_DEFAULTS.timeout);
|
|
76
77
|
const timeoutMinutes = typeof timeout === "string" ? parseTtl(timeout) : undefined;
|
|
77
78
|
if (timeoutMinutes === undefined)
|
|
78
|
-
report(["timeout"], `must be a whole number of minutes or hours from 10m to 5h, not ${
|
|
79
|
+
report(["timeout"], `must be a whole number of minutes or hours from 10m to 5h, not ${describeOptionValue(timeout)}`);
|
|
79
80
|
const keepSandbox = value["keepSandbox"];
|
|
80
81
|
const keepSandboxMinutes = typeof keepSandbox === "string" ? parseKeepTime(keepSandbox) : undefined;
|
|
81
82
|
if (keepSandbox !== undefined && keepSandboxMinutes === undefined)
|
|
82
|
-
report(["keepSandbox"], `must be 0, or a whole number of minutes or hours up to 5h, not ${
|
|
83
|
+
report(["keepSandbox"], `must be 0, or a whole number of minutes or hours up to 5h, not ${describeOptionValue(keepSandbox)}`);
|
|
83
84
|
else if (unsafeSecretEnvVars !== undefined &&
|
|
84
85
|
unsafeSecretEnvVars.length > 0 &&
|
|
85
86
|
keepSandboxMinutes !== undefined &&
|
|
86
87
|
keepSandboxMinutes > 0)
|
|
87
88
|
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");
|
|
88
89
|
const baseRefs = checkBaseRefs(value["baseRefs"], report);
|
|
89
|
-
const region = orDefault(value["region"],
|
|
90
|
+
const region = orDefault(value["region"], VERCEL_SANDBOX_DEFAULTS.region);
|
|
90
91
|
if (!isNonEmptyString(region))
|
|
91
|
-
report(["region"], `must be a non-empty string, not ${
|
|
92
|
-
const runtime = orDefault(value["runtime"],
|
|
92
|
+
report(["region"], `must be a non-empty string, not ${describeOptionValue(region)}`);
|
|
93
|
+
const runtime = orDefault(value["runtime"], VERCEL_SANDBOX_DEFAULTS.runtime);
|
|
93
94
|
if (!isNonEmptyString(runtime))
|
|
94
|
-
report(["runtime"], `must be a non-empty string, not ${
|
|
95
|
+
report(["runtime"], `must be a non-empty string, not ${describeOptionValue(runtime)}`);
|
|
95
96
|
const sandboxes = checkSandboxes(value["sandboxes"], report);
|
|
96
97
|
if (problems.length > 0 ||
|
|
97
98
|
snapshot === undefined ||
|
|
@@ -135,33 +136,33 @@ function checkVcpus(value, report) {
|
|
|
135
136
|
return undefined;
|
|
136
137
|
}
|
|
137
138
|
if (!isRecord(value)) {
|
|
138
|
-
report(["vcpus"], `must be a positive whole number, or { resource, option, per, min, max }, not ${
|
|
139
|
+
report(["vcpus"], `must be a positive whole number, or { resource, option, per, min, max }, not ${describeOptionValue(value)}`);
|
|
139
140
|
return undefined;
|
|
140
141
|
}
|
|
141
|
-
let ok = reportUnknownKeys(value, VCPUS_RULE_KEYS, ["vcpus"], "a
|
|
142
|
+
let ok = reportUnknownKeys(value, VCPUS_RULE_KEYS, ["vcpus"], "a vercelSandbox vcpus rule key", report);
|
|
142
143
|
const resource = value["resource"];
|
|
143
144
|
if (!isNonEmptyString(resource)) {
|
|
144
|
-
report(["vcpus", "resource"], `must be a non-empty string, not ${
|
|
145
|
+
report(["vcpus", "resource"], `must be a non-empty string, not ${describeOptionValue(resource)}`);
|
|
145
146
|
ok = false;
|
|
146
147
|
}
|
|
147
148
|
const option = value["option"];
|
|
148
149
|
if (!isNonEmptyString(option)) {
|
|
149
|
-
report(["vcpus", "option"], `must be a non-empty string, not ${
|
|
150
|
+
report(["vcpus", "option"], `must be a non-empty string, not ${describeOptionValue(option)}`);
|
|
150
151
|
ok = false;
|
|
151
152
|
}
|
|
152
153
|
const per = value["per"];
|
|
153
154
|
if (!isPositiveInteger(per)) {
|
|
154
|
-
report(["vcpus", "per"], `must be a positive whole number, not ${
|
|
155
|
+
report(["vcpus", "per"], `must be a positive whole number, not ${describeOptionValue(per)}`);
|
|
155
156
|
ok = false;
|
|
156
157
|
}
|
|
157
158
|
const min = value["min"];
|
|
158
159
|
if (!isPositiveInteger(min)) {
|
|
159
|
-
report(["vcpus", "min"], `must be a positive whole number, not ${
|
|
160
|
+
report(["vcpus", "min"], `must be a positive whole number, not ${describeOptionValue(min)}`);
|
|
160
161
|
ok = false;
|
|
161
162
|
}
|
|
162
163
|
const max = value["max"];
|
|
163
164
|
if (!isPositiveInteger(max)) {
|
|
164
|
-
report(["vcpus", "max"], `must be a positive whole number, not ${
|
|
165
|
+
report(["vcpus", "max"], `must be a positive whole number, not ${describeOptionValue(max)}`);
|
|
165
166
|
ok = false;
|
|
166
167
|
}
|
|
167
168
|
else if (isPositiveInteger(min) && max < min) {
|
|
@@ -179,7 +180,7 @@ function checkVcpus(value, report) {
|
|
|
179
180
|
: undefined;
|
|
180
181
|
}
|
|
181
182
|
/**
|
|
182
|
-
* The
|
|
183
|
+
* The runner's `sandboxes`: an object whose `max` is a whole number from 1 to `MAX_RUNNER_SANDBOXES`, and whose
|
|
183
184
|
* optional `default` is a whole number from 1 to `MAX_RUNNER_SANDBOXES` or a declared `{ filesPerSandbox, max? }` rule;
|
|
184
185
|
* undefined when absent, and false when it is wrong, which is reported.
|
|
185
186
|
*/
|
|
@@ -187,13 +188,13 @@ function checkSandboxes(value, report) {
|
|
|
187
188
|
if (value === undefined)
|
|
188
189
|
return undefined;
|
|
189
190
|
if (!isRecord(value)) {
|
|
190
|
-
report(["sandboxes"], `must be an object with max, not ${
|
|
191
|
+
report(["sandboxes"], `must be an object with max, not ${describeOptionValue(value)}`);
|
|
191
192
|
return false;
|
|
192
193
|
}
|
|
193
|
-
let ok = reportUnknownKeys(value, SANDBOXES_KEYS, ["sandboxes"], "a
|
|
194
|
+
let ok = reportUnknownKeys(value, SANDBOXES_KEYS, ["sandboxes"], "a vercelSandbox sandboxes key", report);
|
|
194
195
|
const max = value["max"];
|
|
195
196
|
if (!isPositiveInteger(max) || max > MAX_RUNNER_SANDBOXES) {
|
|
196
|
-
report(["sandboxes", "max"], `must be a whole number from 1 to ${MAX_RUNNER_SANDBOXES}, not ${
|
|
197
|
+
report(["sandboxes", "max"], `must be a whole number from 1 to ${MAX_RUNNER_SANDBOXES}, not ${describeOptionValue(max)}`);
|
|
197
198
|
ok = false;
|
|
198
199
|
}
|
|
199
200
|
const rawDefault = value["default"];
|
|
@@ -220,18 +221,18 @@ function checkSandboxesDefault(value, report) {
|
|
|
220
221
|
return undefined;
|
|
221
222
|
}
|
|
222
223
|
if (!isRecord(value)) {
|
|
223
|
-
report(["sandboxes", "default"], `must be a whole number from 1 to ${MAX_RUNNER_SANDBOXES}, or { filesPerSandbox, max? }, not ${
|
|
224
|
+
report(["sandboxes", "default"], `must be a whole number from 1 to ${MAX_RUNNER_SANDBOXES}, or { filesPerSandbox, max? }, not ${describeOptionValue(value)}`);
|
|
224
225
|
return undefined;
|
|
225
226
|
}
|
|
226
|
-
let ok = reportUnknownKeys(value, SANDBOXES_DEFAULT_RULE_KEYS, ["sandboxes", "default"], "a
|
|
227
|
+
let ok = reportUnknownKeys(value, SANDBOXES_DEFAULT_RULE_KEYS, ["sandboxes", "default"], "a vercelSandbox sandboxes default rule key", report);
|
|
227
228
|
const filesPerSandbox = value["filesPerSandbox"];
|
|
228
229
|
if (!isPositiveInteger(filesPerSandbox)) {
|
|
229
|
-
report(["sandboxes", "default", "filesPerSandbox"], `must be a positive whole number, not ${
|
|
230
|
+
report(["sandboxes", "default", "filesPerSandbox"], `must be a positive whole number, not ${describeOptionValue(filesPerSandbox)}`);
|
|
230
231
|
ok = false;
|
|
231
232
|
}
|
|
232
233
|
const max = value["max"];
|
|
233
234
|
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 ${
|
|
235
|
+
report(["sandboxes", "default", "max"], `must be a whole number from 1 to ${MAX_RUNNER_SANDBOXES}, not ${describeOptionValue(max)}`);
|
|
235
236
|
ok = false;
|
|
236
237
|
}
|
|
237
238
|
if (!ok)
|
|
@@ -243,18 +244,18 @@ function checkSandboxesDefault(value, report) {
|
|
|
243
244
|
}
|
|
244
245
|
function checkSnapshot(value, report) {
|
|
245
246
|
if (!isRecord(value)) {
|
|
246
|
-
report(["snapshot"], `must be an object of vcpus, toolchains, prebuild, and an optional summary, not ${
|
|
247
|
+
report(["snapshot"], `must be an object of vcpus, toolchains, prebuild, and an optional summary, not ${describeOptionValue(value)}`);
|
|
247
248
|
return undefined;
|
|
248
249
|
}
|
|
249
|
-
let ok = reportUnknownKeys(value, SNAPSHOT_KEYS, ["snapshot"], "a
|
|
250
|
+
let ok = reportUnknownKeys(value, SNAPSHOT_KEYS, ["snapshot"], "a vercelSandbox snapshot key", report);
|
|
250
251
|
const vcpus = value["vcpus"];
|
|
251
252
|
if (!isPositiveInteger(vcpus)) {
|
|
252
|
-
report(["snapshot", "vcpus"], `must be a positive whole number, not ${
|
|
253
|
+
report(["snapshot", "vcpus"], `must be a positive whole number, not ${describeOptionValue(vcpus)}`);
|
|
253
254
|
ok = false;
|
|
254
255
|
}
|
|
255
256
|
const summary = value["summary"];
|
|
256
257
|
if (summary !== undefined && !isNonEmptyString(summary)) {
|
|
257
|
-
report(["snapshot", "summary"], `must be a non-empty string, not ${
|
|
258
|
+
report(["snapshot", "summary"], `must be a non-empty string, not ${describeOptionValue(summary)}`);
|
|
258
259
|
ok = false;
|
|
259
260
|
}
|
|
260
261
|
const toolchains = checkSteps(value["toolchains"], ["snapshot", "toolchains"], true, report);
|
|
@@ -270,10 +271,10 @@ function checkSnapshot(value, report) {
|
|
|
270
271
|
}
|
|
271
272
|
function checkRun(value, report) {
|
|
272
273
|
if (!isRecord(value)) {
|
|
273
|
-
report(["run"], `must be an object of install and build steps, not ${
|
|
274
|
+
report(["run"], `must be an object of install and build steps, not ${describeOptionValue(value)}`);
|
|
274
275
|
return undefined;
|
|
275
276
|
}
|
|
276
|
-
const ok = reportUnknownKeys(value, RUN_KEYS, ["run"], "a
|
|
277
|
+
const ok = reportUnknownKeys(value, RUN_KEYS, ["run"], "a vercelSandbox run key", report);
|
|
277
278
|
const install = checkStep(value["install"], ["run", "install"], false, report);
|
|
278
279
|
const build = checkStep(value["build"], ["run", "build"], false, report);
|
|
279
280
|
return ok && install !== undefined && build !== undefined ? { install, build } : undefined;
|
|
@@ -286,7 +287,7 @@ function checkSteps(value, path, allowBaseFiles, report) {
|
|
|
286
287
|
return undefined;
|
|
287
288
|
}
|
|
288
289
|
if (!Array.isArray(value)) {
|
|
289
|
-
report(path, `must be a list of steps, not ${
|
|
290
|
+
report(path, `must be a list of steps, not ${describeOptionValue(value)}`);
|
|
290
291
|
return undefined;
|
|
291
292
|
}
|
|
292
293
|
const steps = value.map((step, index) => allowBaseFiles
|
|
@@ -297,7 +298,7 @@ function checkSteps(value, path, allowBaseFiles, report) {
|
|
|
297
298
|
function checkStep(value, path, allowBaseFiles, report) {
|
|
298
299
|
if (!isRecord(value)) {
|
|
299
300
|
const shape = allowBaseFiles ? "{ label, script, baseFiles? }" : "{ label, script }";
|
|
300
|
-
report(path, `must be a step, ${shape}, not ${
|
|
301
|
+
report(path, `must be a step, ${shape}, not ${describeOptionValue(value)}`);
|
|
301
302
|
return undefined;
|
|
302
303
|
}
|
|
303
304
|
const allowedKeys = allowBaseFiles ? TOOLCHAIN_STEP_KEYS : STEP_KEYS;
|
|
@@ -306,7 +307,7 @@ function checkStep(value, path, allowBaseFiles, report) {
|
|
|
306
307
|
if (allowedKeys.has(key))
|
|
307
308
|
continue;
|
|
308
309
|
report([...path, key], key === "secrets"
|
|
309
|
-
? "is not a step key: every
|
|
310
|
+
? "is not a step key: every step of the runner gets every credential runner.credentials declares"
|
|
310
311
|
: key === "baseFiles"
|
|
311
312
|
? "is only allowed on snapshot.toolchains steps: this step already sees the base's files"
|
|
312
313
|
: "is not a step key");
|
|
@@ -315,11 +316,11 @@ function checkStep(value, path, allowBaseFiles, report) {
|
|
|
315
316
|
const label = value["label"];
|
|
316
317
|
const script = value["script"];
|
|
317
318
|
if (!isNonEmptyString(label)) {
|
|
318
|
-
report([...path, "label"], `must be a non-empty string, not ${
|
|
319
|
+
report([...path, "label"], `must be a non-empty string, not ${describeOptionValue(label)}`);
|
|
319
320
|
ok = false;
|
|
320
321
|
}
|
|
321
322
|
if (!isNonEmptyString(script)) {
|
|
322
|
-
report([...path, "script"], `must be a non-empty string, not ${
|
|
323
|
+
report([...path, "script"], `must be a non-empty string, not ${describeOptionValue(script)}`);
|
|
323
324
|
ok = false;
|
|
324
325
|
}
|
|
325
326
|
if (!allowBaseFiles)
|
|
@@ -339,7 +340,7 @@ function checkBaseFiles(value, path, report) {
|
|
|
339
340
|
if (value === undefined)
|
|
340
341
|
return undefined;
|
|
341
342
|
if (!Array.isArray(value)) {
|
|
342
|
-
report(path, `must be a list of relative file paths, not ${
|
|
343
|
+
report(path, `must be a list of relative file paths, not ${describeOptionValue(value)}`);
|
|
343
344
|
return null;
|
|
344
345
|
}
|
|
345
346
|
let ok = true;
|
|
@@ -348,7 +349,7 @@ function checkBaseFiles(value, path, report) {
|
|
|
348
349
|
value.forEach((entry, index) => {
|
|
349
350
|
const at = [...path, String(index)];
|
|
350
351
|
if (!isRelativeFilePath(entry)) {
|
|
351
|
-
report(at, `must be a relative file path without leading "/", "./", "..", or trailing "/", not ${
|
|
352
|
+
report(at, `must be a relative file path without leading "/", "./", "..", or trailing "/", not ${describeOptionValue(entry)}`);
|
|
352
353
|
ok = false;
|
|
353
354
|
}
|
|
354
355
|
else if (seen.has(entry)) {
|
|
@@ -366,7 +367,7 @@ function checkEnv(value, report) {
|
|
|
366
367
|
if (value === undefined)
|
|
367
368
|
return {};
|
|
368
369
|
if (!isRecord(value)) {
|
|
369
|
-
report(["env"], `must be an object of strings, not ${
|
|
370
|
+
report(["env"], `must be an object of strings, not ${describeOptionValue(value)}`);
|
|
370
371
|
return undefined;
|
|
371
372
|
}
|
|
372
373
|
let ok = true;
|
|
@@ -377,7 +378,7 @@ function checkEnv(value, report) {
|
|
|
377
378
|
ok = false;
|
|
378
379
|
}
|
|
379
380
|
else if (typeof variable !== "string") {
|
|
380
|
-
report(["env", key], `must be a string, not ${
|
|
381
|
+
report(["env", key], `must be a string, not ${describeOptionValue(variable)}`);
|
|
381
382
|
ok = false;
|
|
382
383
|
}
|
|
383
384
|
else
|
|
@@ -386,14 +387,14 @@ function checkEnv(value, report) {
|
|
|
386
387
|
return ok ? env : undefined;
|
|
387
388
|
}
|
|
388
389
|
/**
|
|
389
|
-
* The
|
|
390
|
+
* The runner's `allowedDomains`: a non-empty list of domains (`ALLOWED_DOMAIN_PATTERN`), none listed twice; undefined
|
|
390
391
|
* when absent, for full access, and null when it is wrong.
|
|
391
392
|
*/
|
|
392
393
|
function checkAllowedDomains(value, report) {
|
|
393
394
|
if (value === undefined)
|
|
394
395
|
return undefined;
|
|
395
396
|
if (!Array.isArray(value)) {
|
|
396
|
-
report(["allowedDomains"], `must be a list of domains, such as ["registry.npmjs.org", "*.example.com"], not ${
|
|
397
|
+
report(["allowedDomains"], `must be a list of domains, such as ["registry.npmjs.org", "*.example.com"], not ${describeOptionValue(value)}`);
|
|
397
398
|
return null;
|
|
398
399
|
}
|
|
399
400
|
if (value.length === 0) {
|
|
@@ -409,7 +410,7 @@ function checkAllowedDomains(value, report) {
|
|
|
409
410
|
ok = false;
|
|
410
411
|
}
|
|
411
412
|
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 ${
|
|
413
|
+
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
414
|
ok = false;
|
|
414
415
|
}
|
|
415
416
|
else if (seen.has(domain)) {
|
|
@@ -423,15 +424,15 @@ function checkAllowedDomains(value, report) {
|
|
|
423
424
|
}
|
|
424
425
|
function checkBaseRefs(value, report) {
|
|
425
426
|
if (value === undefined)
|
|
426
|
-
return [...
|
|
427
|
+
return [...VERCEL_SANDBOX_DEFAULTS.baseRefs];
|
|
427
428
|
if (!Array.isArray(value) || value.length === 0) {
|
|
428
|
-
report(["baseRefs"], `must be a non-empty list of refs, not ${
|
|
429
|
+
report(["baseRefs"], `must be a non-empty list of refs, not ${describeOptionValue(value)}`);
|
|
429
430
|
return undefined;
|
|
430
431
|
}
|
|
431
432
|
let ok = true;
|
|
432
433
|
value.forEach((ref, index) => {
|
|
433
434
|
if (!isNonEmptyString(ref)) {
|
|
434
|
-
report(["baseRefs", String(index)], `must be a non-empty string, not ${
|
|
435
|
+
report(["baseRefs", String(index)], `must be a non-empty string, not ${describeOptionValue(ref)}`);
|
|
435
436
|
ok = false;
|
|
436
437
|
}
|
|
437
438
|
});
|
|
@@ -449,29 +450,29 @@ export function declaredBaseFilePaths(toolchains) {
|
|
|
449
450
|
return [...paths].toSorted((a, b) => (a < b ? -1 : a > b ? 1 : 0));
|
|
450
451
|
}
|
|
451
452
|
/**
|
|
452
|
-
* The runner sandbox's vCPUs for `run`: the
|
|
453
|
+
* The runner sandbox's vCPUs for `run`: the runner's number, or the declared resource-scaling rule evaluated against
|
|
453
454
|
* `run.resources` and `run.sandboxes`. When the named resource is absent from the run, `min` is used. When the named
|
|
454
455
|
* resource is present and its named option is missing or not a non-negative finite number, returns a problem.
|
|
455
456
|
*/
|
|
456
|
-
export function resolveVcpus(
|
|
457
|
-
if (typeof
|
|
458
|
-
return { ok: true, vcpus:
|
|
459
|
-
const { resource, option, per, min, max } =
|
|
460
|
-
const
|
|
461
|
-
if (
|
|
457
|
+
export function resolveVcpus(options, run) {
|
|
458
|
+
if (typeof options.vcpus === "number")
|
|
459
|
+
return { ok: true, vcpus: options.vcpus };
|
|
460
|
+
const { resource, option, per, min, max } = options.vcpus;
|
|
461
|
+
const resourceOptions = Object.hasOwn(run.resources, resource) ? run.resources[resource] : undefined;
|
|
462
|
+
if (resourceOptions === undefined)
|
|
462
463
|
return { ok: true, vcpus: min };
|
|
463
|
-
const raw = Object.hasOwn(
|
|
464
|
+
const raw = Object.hasOwn(resourceOptions, option) ? resourceOptions[option] : undefined;
|
|
464
465
|
if (typeof raw !== "number" || !Number.isFinite(raw) || raw < 0) {
|
|
465
466
|
return {
|
|
466
467
|
ok: false,
|
|
467
|
-
problem: `resource "${resource}" option "${option}" must be a non-negative number, not ${
|
|
468
|
+
problem: `resource "${resource}" option "${option}" must be a non-negative number, not ${describeOptionValue(raw)}`,
|
|
468
469
|
};
|
|
469
470
|
}
|
|
470
471
|
const perSandbox = Math.ceil(raw / Math.max(1, run.sandboxes));
|
|
471
472
|
return { ok: true, vcpus: Math.min(max, Math.max(min, per * perSandbox)) };
|
|
472
473
|
}
|
|
473
474
|
/**
|
|
474
|
-
* The number of runner sandboxes `runner.sandboxes.default` gives a run with test plan `testPlan`: the
|
|
475
|
+
* The number of runner sandboxes `runner.sandboxes.default` gives a run with test plan `testPlan`: the runner's number,
|
|
475
476
|
* or the declared `{ filesPerSandbox, max? }` rule evaluated against `testPlan`. A number above `sandboxes.max` is not
|
|
476
477
|
* a problem here: the run lowers it to `sandboxes.max` and says so.
|
|
477
478
|
*/
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { type SecretSource } from "../sdk/extension/index.ts";
|
|
2
|
-
import { type Report } from "./
|
|
2
|
+
import { type Report } from "./vercel-sandbox-check.ts";
|
|
3
3
|
/**
|
|
4
4
|
* One sandbox credential declared in `runner.credentials`: a header the Sandbox firewall adds to a sandbox's requests
|
|
5
|
-
* to one domain while the
|
|
5
|
+
* to one domain while the runner's steps and the command run, with its value read from `source` as the run starts. The
|
|
6
6
|
* value never enters the sandbox.
|
|
7
7
|
*/
|
|
8
8
|
export interface CredentialDeclaration {
|
|
@@ -46,10 +46,10 @@ export interface UnsafeSecretEnvVar {
|
|
|
46
46
|
readonly source: SecretSource;
|
|
47
47
|
}
|
|
48
48
|
/**
|
|
49
|
-
* The sorted, unique secret source identities
|
|
50
|
-
* hashing into the runner snapshot key.
|
|
49
|
+
* The sorted, unique secret source identities checked runner options' credentials read from (such as
|
|
50
|
+
* `"env:NPM_AUTH"`), for hashing into the runner snapshot key.
|
|
51
51
|
*/
|
|
52
|
-
export declare function credentialSourceIds(
|
|
52
|
+
export declare function credentialSourceIds(options: {
|
|
53
53
|
readonly credentials: readonly Required<CredentialDeclaration>[];
|
|
54
54
|
}): readonly string[];
|
|
55
55
|
/**
|
|
@@ -60,7 +60,7 @@ export declare function credentialSourceIds(recipe: {
|
|
|
60
60
|
*/
|
|
61
61
|
export declare function checkCredentials(value: unknown, report: Report): readonly Required<CredentialDeclaration>[] | undefined;
|
|
62
62
|
/**
|
|
63
|
-
* The
|
|
63
|
+
* The runner's `unsafeSecretEnvVars`: a list of `{ name, source }` plain objects, each exposing a distinct environment
|
|
64
64
|
* variable `name` that neither storm sets for the command (`STORM_RUN`, `RESERVED_UNSAFE_SECRET_ENV_VAR_NAMES`,
|
|
65
65
|
* `LD_*`, `DYLD_*`) nor `runner.env` sets, read from a `SecretSource` that `runner.credentials` doesn't already read.
|
|
66
66
|
*/
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
// Secret declarations on a runner
|
|
2
|
-
// and `runner.unsafeSecretEnvVars` (environment variables exposed to the command alone).
|
|
3
|
-
// `
|
|
1
|
+
// Secret declarations on a Vercel Sandbox runner: `runner.credentials` (sandbox credentials injected by the Sandbox
|
|
2
|
+
// firewall) and `runner.unsafeSecretEnvVars` (environment variables exposed to the command alone).
|
|
3
|
+
// `vercel-sandbox-options.ts` coordinates `checkVercelSandboxOptions` and delegates both secret keys here.
|
|
4
4
|
import { ENV_VAR_NAME_PATTERN, ENV_VAR_NAME_RULE, secretSourceId } from "../sdk/extension/index.js";
|
|
5
5
|
import { RUN_PAYLOAD_VARIABLE } from "../sdk/run/launcher.js";
|
|
6
|
-
import {
|
|
6
|
+
import { describeOptionValue, reportUnknownKeys } from "./vercel-sandbox-check.js";
|
|
7
7
|
const CREDENTIAL_KEYS = new Set(["domain", "header", "source", "requests"]);
|
|
8
8
|
const UNSAFE_SECRET_ENV_VAR_KEYS = new Set(["name", "source"]);
|
|
9
9
|
const ENV_SOURCE_KEYS = new Set(["kind", "name"]);
|
|
@@ -38,11 +38,11 @@ const RESERVED_UNSAFE_SECRET_ENV_VAR_NAMES = new Set([
|
|
|
38
38
|
/** Prefixes of the dynamic loader's variables, which an unsafe secret environment variable's name can't start with. */
|
|
39
39
|
const RESERVED_UNSAFE_SECRET_ENV_VAR_PREFIXES = ["LD_", "DYLD_"];
|
|
40
40
|
/**
|
|
41
|
-
* The sorted, unique secret source identities
|
|
42
|
-
* hashing into the runner snapshot key.
|
|
41
|
+
* The sorted, unique secret source identities checked runner options' credentials read from (such as
|
|
42
|
+
* `"env:NPM_AUTH"`), for hashing into the runner snapshot key.
|
|
43
43
|
*/
|
|
44
|
-
export function credentialSourceIds(
|
|
45
|
-
return [...new Set(
|
|
44
|
+
export function credentialSourceIds(options) {
|
|
45
|
+
return [...new Set(options.credentials.map(({ source }) => secretSourceId(source)))].toSorted();
|
|
46
46
|
}
|
|
47
47
|
/**
|
|
48
48
|
* The sandbox credentials: a list of `{ domain, header?, source, requests? }` (`checkCredential`), with no two going
|
|
@@ -54,7 +54,7 @@ export function checkCredentials(value, report) {
|
|
|
54
54
|
if (value === undefined)
|
|
55
55
|
return [];
|
|
56
56
|
if (!Array.isArray(value)) {
|
|
57
|
-
report(["credentials"], `must be a list of credentials, each { domain, header?, source, requests? }, not ${
|
|
57
|
+
report(["credentials"], `must be a list of credentials, each { domain, header?, source, requests? }, not ${describeOptionValue(value)}`);
|
|
58
58
|
return undefined;
|
|
59
59
|
}
|
|
60
60
|
let ok = true;
|
|
@@ -94,18 +94,18 @@ export function checkCredentials(value, report) {
|
|
|
94
94
|
*/
|
|
95
95
|
function checkCredential(value, path, report) {
|
|
96
96
|
if (!isPlainObject(value)) {
|
|
97
|
-
report(path, `must be { domain, header?, source, requests? }, not ${
|
|
97
|
+
report(path, `must be { domain, header?, source, requests? }, not ${describeOptionValue(value)}`);
|
|
98
98
|
return undefined;
|
|
99
99
|
}
|
|
100
100
|
let ok = reportUnknownKeys(value, CREDENTIAL_KEYS, path, "a credential key", report);
|
|
101
101
|
const domain = value["domain"];
|
|
102
102
|
if (typeof domain !== "string" || !HOST_PATTERN.test(domain)) {
|
|
103
|
-
report([...path, "domain"], `must be a bare hostname, such as registry.example.com: lowercase letters, digits, dots, and hyphens, with at least one dot, and no scheme, port, path, or wildcard, not ${
|
|
103
|
+
report([...path, "domain"], `must be a bare hostname, such as registry.example.com: lowercase letters, digits, dots, and hyphens, with at least one dot, and no scheme, port, path, or wildcard, not ${describeOptionValue(domain)}`);
|
|
104
104
|
ok = false;
|
|
105
105
|
}
|
|
106
106
|
const header = value["header"] === undefined ? DEFAULT_CREDENTIAL_HEADER : value["header"];
|
|
107
107
|
if (typeof header !== "string" || !HEADER_PATTERN.test(header)) {
|
|
108
|
-
report([...path, "header"], `must be an HTTP header name, such as authorization, not ${
|
|
108
|
+
report([...path, "header"], `must be an HTTP header name, such as authorization, not ${describeOptionValue(header)}`);
|
|
109
109
|
ok = false;
|
|
110
110
|
}
|
|
111
111
|
else if (REFUSED_HEADERS.has(header.toLowerCase())) {
|
|
@@ -117,7 +117,7 @@ function checkCredential(value, path, report) {
|
|
|
117
117
|
ok = false;
|
|
118
118
|
const requests = value["requests"] === undefined ? "read" : value["requests"];
|
|
119
119
|
if (requests !== "read" && requests !== "all") {
|
|
120
|
-
report([...path, "requests"], `must be "read" or "all", not ${
|
|
120
|
+
report([...path, "requests"], `must be "read" or "all", not ${describeOptionValue(requests)}`);
|
|
121
121
|
ok = false;
|
|
122
122
|
}
|
|
123
123
|
return ok && source !== undefined
|
|
@@ -132,12 +132,12 @@ function checkCredential(value, path, report) {
|
|
|
132
132
|
/** One secret source: a plain object with exact keys `{ kind: "env", name: <environment variable name> }`. */
|
|
133
133
|
function checkSecretSource(value, path, report) {
|
|
134
134
|
if (!isPlainObject(value)) {
|
|
135
|
-
report(path, `must be a secret source, { kind: "env", name }, not ${
|
|
135
|
+
report(path, `must be a secret source, { kind: "env", name }, not ${describeOptionValue(value)}`);
|
|
136
136
|
return undefined;
|
|
137
137
|
}
|
|
138
138
|
const kind = value["kind"];
|
|
139
139
|
if (kind !== "env") {
|
|
140
|
-
report([...path, "kind"], `must be "env", not ${
|
|
140
|
+
report([...path, "kind"], `must be "env", not ${describeOptionValue(kind)}`);
|
|
141
141
|
if (kind !== undefined)
|
|
142
142
|
return undefined;
|
|
143
143
|
}
|
|
@@ -146,13 +146,13 @@ function checkSecretSource(value, path, report) {
|
|
|
146
146
|
ok = false;
|
|
147
147
|
const name = value["name"];
|
|
148
148
|
if (typeof name !== "string" || !ENV_VAR_NAME_PATTERN.test(name)) {
|
|
149
|
-
report([...path, "name"], `must be ${ENV_VAR_NAME_RULE}, not ${
|
|
149
|
+
report([...path, "name"], `must be ${ENV_VAR_NAME_RULE}, not ${describeOptionValue(name)}`);
|
|
150
150
|
ok = false;
|
|
151
151
|
}
|
|
152
152
|
return ok ? { kind: "env", name: name } : undefined;
|
|
153
153
|
}
|
|
154
154
|
/**
|
|
155
|
-
* The
|
|
155
|
+
* The runner's `unsafeSecretEnvVars`: a list of `{ name, source }` plain objects, each exposing a distinct environment
|
|
156
156
|
* variable `name` that neither storm sets for the command (`STORM_RUN`, `RESERVED_UNSAFE_SECRET_ENV_VAR_NAMES`,
|
|
157
157
|
* `LD_*`, `DYLD_*`) nor `runner.env` sets, read from a `SecretSource` that `runner.credentials` doesn't already read.
|
|
158
158
|
*/
|
|
@@ -160,7 +160,7 @@ export function checkUnsafeSecretEnvVars(value, env, credentials, report) {
|
|
|
160
160
|
if (value === undefined)
|
|
161
161
|
return [];
|
|
162
162
|
if (!Array.isArray(value)) {
|
|
163
|
-
report(["unsafeSecretEnvVars"], `must be a list of unsafe secret environment variables, each { name, source }, not ${
|
|
163
|
+
report(["unsafeSecretEnvVars"], `must be a list of unsafe secret environment variables, each { name, source }, not ${describeOptionValue(value)}`);
|
|
164
164
|
return undefined;
|
|
165
165
|
}
|
|
166
166
|
let ok = true;
|
|
@@ -170,7 +170,7 @@ export function checkUnsafeSecretEnvVars(value, env, credentials, report) {
|
|
|
170
170
|
value.forEach((entry, index) => {
|
|
171
171
|
const path = ["unsafeSecretEnvVars", String(index)];
|
|
172
172
|
if (!isPlainObject(entry)) {
|
|
173
|
-
report(path, `must be { name, source }, not ${
|
|
173
|
+
report(path, `must be { name, source }, not ${describeOptionValue(entry)}`);
|
|
174
174
|
ok = false;
|
|
175
175
|
return;
|
|
176
176
|
}
|
|
@@ -178,7 +178,7 @@ export function checkUnsafeSecretEnvVars(value, env, credentials, report) {
|
|
|
178
178
|
const name = entry["name"];
|
|
179
179
|
const namePath = [...path, "name"];
|
|
180
180
|
if (typeof name !== "string" || !ENV_VAR_NAME_PATTERN.test(name)) {
|
|
181
|
-
report(namePath, `must be ${ENV_VAR_NAME_RULE}, not ${
|
|
181
|
+
report(namePath, `must be ${ENV_VAR_NAME_RULE}, not ${describeOptionValue(name)}`);
|
|
182
182
|
entryOk = false;
|
|
183
183
|
}
|
|
184
184
|
else if (name === RUN_PAYLOAD_VARIABLE) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type CommandTree, type Mount } from "@vercel/clinkr";
|
|
1
|
+
import { type CommandTree, type ManifestEntry, type Mount } from "@vercel/clinkr";
|
|
2
2
|
export { type CommandMetadata, type CommandTree, commandTree, defineOutcomes, renderOutcome, type Row, type Warning, } from "@vercel/clinkr";
|
|
3
3
|
/**
|
|
4
4
|
* What an extension's author declares of its commands: its command tree, whose commands take `App`, the tree's own app;
|
|
@@ -33,12 +33,17 @@ export interface ExtensionCommands<LauncherApp> {
|
|
|
33
33
|
readonly mount: (placement: ExtensionCommandsPlacement) => Mount<LauncherApp>;
|
|
34
34
|
}
|
|
35
35
|
/** Where the launcher mounts an extension's commands: the launcher's choice, never the extension's. */
|
|
36
|
-
export
|
|
36
|
+
export type ExtensionCommandsPlacement = {
|
|
37
37
|
/** Where the tree's commands sit in `storm`, such as `["ext", "<name>"]`. */
|
|
38
38
|
readonly path: readonly string[];
|
|
39
39
|
/** Storm's code root (`src/` or `dist/`), which the tree's directory is under. */
|
|
40
40
|
readonly root: string;
|
|
41
|
-
}
|
|
41
|
+
} | {
|
|
42
|
+
/** Where the tree's commands sit in `storm`, such as `["ext", "<name>"]`. */
|
|
43
|
+
readonly path: readonly string[];
|
|
44
|
+
/** Pre-built static manifest entries for compiled or bundled builds. */
|
|
45
|
+
readonly manifest: Readonly<Record<string, ManifestEntry>>;
|
|
46
|
+
};
|
|
42
47
|
/** Declares an extension's commands. Only this function calls Clinkr's `mount`, since it knows the tree's app type. */
|
|
43
48
|
export declare function defineExtensionCommands<LauncherApp, App>(definition: ExtensionCommandsDefinition<LauncherApp, App>): ExtensionCommands<LauncherApp>;
|
|
44
49
|
/** A Clinkr example written as `{ argv, description? }`: the arguments after the command's name, and what it does. */
|
|
@@ -20,7 +20,9 @@ export function defineExtensionCommands(definition) {
|
|
|
20
20
|
return {
|
|
21
21
|
description,
|
|
22
22
|
directory,
|
|
23
|
-
mount: (
|
|
23
|
+
mount: (placement) => "manifest" in placement
|
|
24
|
+
? mount(tree.manifest(placement.manifest), { path: placement.path, description, app })
|
|
25
|
+
: mount(tree.directory(join(placement.root, directory)), { path: placement.path, description, app }),
|
|
24
26
|
};
|
|
25
27
|
}
|
|
26
28
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CredentialFailure, MintFailure, MintTarget, TokenRequestFailure } from "./credential-source.ts";
|
|
1
|
+
import type { CredentialFailure, MintFailure, MintTarget, TokenRequestFailure, VercelOidcTokenFailure } from "./credential-source.ts";
|
|
2
2
|
/** One cause and one fix for a credential source's failure, worded for the person running storm. */
|
|
3
3
|
export interface CredentialDiagnosis {
|
|
4
4
|
readonly cause: string;
|
|
@@ -8,5 +8,7 @@ export interface CredentialDiagnosis {
|
|
|
8
8
|
export declare function describeMintFailure(failure: MintFailure, target: MintTarget): CredentialDiagnosis;
|
|
9
9
|
/** Names the cause of a failed GitHub Actions OIDC token request and the one fix for it. */
|
|
10
10
|
export declare function describeTokenRequestFailure(failure: TokenRequestFailure): CredentialDiagnosis;
|
|
11
|
+
/** Names the cause of a failed `VERCEL_OIDC_TOKEN` read and the one fix for it. */
|
|
12
|
+
export declare function describeVercelOidcTokenFailure(failure: VercelOidcTokenFailure): CredentialDiagnosis;
|
|
11
13
|
/** Names the cause of a credential source's failure and the one fix for it, for whichever source it was. */
|
|
12
14
|
export declare function describeCredentialFailure(failure: CredentialFailure): CredentialDiagnosis;
|