@cnc-tools/storm 0.17.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 +37 -39
- package/dist/build-info.js +1 -1
- package/dist/chunks/{chunk-4WAMTUWZ.js → chunk-24UYAK4R.js} +88 -67
- package/dist/chunks/{chunk-RNAS7JHE.js → chunk-2JMWUKH3.js} +710 -102
- package/dist/chunks/{chunk-YEPFSLQR.js → chunk-3VXZONGE.js} +2 -2
- package/dist/chunks/{chunk-D27KILIA.js → chunk-55O4FCN4.js} +1 -1
- package/dist/chunks/{chunk-JN3YY6ZH.js → chunk-AS37D43E.js} +27 -20
- package/dist/chunks/{chunk-2VP4GRJM.js → chunk-CQAY6GLP.js} +54 -13
- package/dist/chunks/{chunk-MR77L2GK.js → chunk-DZLU7BYK.js} +5 -5
- package/dist/chunks/{chunk-LKTZ5OXS.js → chunk-EI3XDCEI.js} +1 -1
- package/dist/chunks/{chunk-FNBB6V4R.js → chunk-FDUY3BNF.js} +1 -1
- package/dist/chunks/{chunk-RWIXDDCK.js → chunk-GUCCYCIO.js} +3 -3
- package/dist/chunks/{chunk-6UHIJXZG.js → chunk-HBI4LEMH.js} +2 -2
- package/dist/chunks/{chunk-CKGZA25H.js → chunk-K4MDQPLW.js} +1 -1
- package/dist/chunks/{chunk-F4MOYHRY.js → chunk-KK7PAWIZ.js} +1 -1
- package/dist/chunks/{chunk-GRT3UIBV.js → chunk-KQ5FXRUD.js} +1 -1
- package/dist/chunks/{chunk-WV3DP6NR.js → chunk-LKXHGGGX.js} +1 -1
- package/dist/chunks/{chunk-4O5C2XGJ.js → chunk-LOGHIUUB.js} +6 -6
- package/dist/chunks/{chunk-7DZE67QM.js → chunk-OEPFINFT.js} +2 -2
- package/dist/chunks/{chunk-HWIQ2S7K.js → chunk-OI4AP6Z7.js} +3 -3
- package/dist/chunks/{chunk-DADEYJDW.js → chunk-PMBQWVTW.js} +6 -6
- package/dist/chunks/{chunk-HP3CURSZ.js → chunk-SZMYIIG2.js} +2 -2
- package/dist/chunks/{chunk-2RNDPDTJ.js → chunk-TXCOFC7N.js} +2 -2
- package/dist/chunks/{chunk-BCBKYOHW.js → chunk-UXD3TVWM.js} +1 -1
- package/dist/chunks/{chunk-M7EKRGVD.js → chunk-WNW2QXQK.js} +1 -1
- package/dist/chunks/{live-app-R76JQXZL.js → live-app-UY7BEDUN.js} +9 -7
- package/dist/cli.d.ts +28 -0
- package/dist/cli.js +64 -0
- package/dist/commands/exec/across-sandboxes-outcomes.d.ts +1 -1
- package/dist/commands/exec/across-sandboxes-outcomes.js +1 -1
- package/dist/commands/exec/before-run.d.ts +1 -1
- package/dist/commands/exec/command.d.ts +36 -12
- package/dist/commands/exec/command.js +18 -18
- package/dist/commands/exec/execute-run.js +1 -1
- package/dist/commands/exec/outcomes.d.ts +71 -15
- package/dist/commands/exec/outcomes.js +46 -6
- package/dist/commands/exec/plan-run.d.ts +1 -1
- package/dist/commands/exec/plan-run.js +8 -3
- package/dist/commands/exec/run-metadata.js +1 -1
- package/dist/commands/exec/run-summary.js +1 -1
- package/dist/commands/runs/facts.d.ts +1 -1
- package/dist/commands/runs/facts.js +2 -2
- package/dist/commands/runs/list/command.d.ts +2 -2
- package/dist/commands/runs/list/command.js +9 -9
- package/dist/commands/runs/list/outcomes.d.ts +1 -1
- package/dist/commands/runs/logs/command.js +9 -9
- package/dist/commands/runs/show/command.d.ts +2 -2
- package/dist/commands/runs/show/command.js +16 -16
- package/dist/commands/runs/show/metadata.js +1 -1
- package/dist/commands/runs/show/outcomes.d.ts +1 -1
- package/dist/commands/runs/show/outcomes.js +1 -1
- package/dist/commands/snapshots/build/command.d.ts +22 -14
- package/dist/commands/snapshots/build/command.js +32 -30
- package/dist/commands/snapshots/build/metadata.js +1 -1
- package/dist/commands/snapshots/build/outcomes.d.ts +14 -10
- package/dist/commands/snapshots/build/outcomes.js +1 -1
- package/dist/commands/snapshots/list/command.d.ts +2 -2
- package/dist/commands/snapshots/list/command.js +19 -19
- package/dist/commands/snapshots/list/outcomes.d.ts +2 -2
- package/dist/commands/snapshots/list/outcomes.js +3 -3
- package/dist/commands/snapshots/prune/command.js +14 -14
- package/dist/commands/suites/list/command.js +10 -10
- package/dist/commands/test/command.d.ts +36 -12
- package/dist/commands/test/command.js +20 -20
- package/dist/commands/test/outcomes.d.ts +18 -6
- package/dist/config-file/define.d.ts +1 -1
- package/dist/config-file/toolchain.d.ts +13 -3
- package/dist/config-file/toolchain.js +41 -5
- package/dist/context.d.ts +3 -1
- package/dist/context.js +2 -1
- package/dist/core/outcomes.d.ts +1 -1
- package/dist/core/run.js +1 -1
- package/dist/extension-commands.d.ts +2 -7
- package/dist/extension-commands.js +3 -17
- package/dist/extensions/testserver/commands/pool/create/command.js +3 -3
- package/dist/extensions/testserver/commands/pool/list/command.js +2 -2
- package/dist/run-directory/recording.js +1 -1
- package/dist/run-directory/run-record.d.ts +5 -5
- package/dist/run-directory/run-record.js +5 -5
- package/dist/runner/build-snapshots.d.ts +5 -0
- package/dist/runner/build-snapshots.js +11 -5
- package/dist/runner/gateways.d.ts +37 -4
- package/dist/runner/gh.d.ts +42 -0
- package/dist/runner/gh.js +58 -0
- package/dist/runner/index.d.ts +5 -4
- package/dist/runner/index.js +3 -2
- 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-gateway.js +12 -2
- package/dist/runner/live/snapshot-records.js +10 -9
- package/dist/runner/local-snapshot-index.d.ts +11 -5
- package/dist/runner/local-snapshot-index.js +13 -14
- package/dist/runner/ready.d.ts +1 -1
- package/dist/runner/ready.js +1 -1
- package/dist/runner/scope.d.ts +5 -2
- package/dist/runner/scope.js +6 -2
- package/dist/runner/secrets.d.ts +37 -14
- package/dist/runner/secrets.js +218 -25
- package/dist/runner/session.js +3 -0
- package/dist/runner/shared-snapshot-entry.d.ts +3 -3
- package/dist/runner/shared-snapshot-entry.js +4 -4
- package/dist/runner/shared-snapshot-list.d.ts +1 -1
- package/dist/runner/shared-snapshot-list.js +1 -1
- package/dist/runner/shared-snapshot-lookup.d.ts +1 -1
- package/dist/runner/shared-snapshot-lookup.js +1 -1
- package/dist/runner/snapshot-build.js +54 -25
- package/dist/runner/snapshot-choice.js +1 -0
- package/dist/runner/snapshot-inspect.js +2 -5
- package/dist/runner/snapshot-key.d.ts +21 -7
- package/dist/runner/snapshot-key.js +31 -7
- package/dist/runner/snapshot-source.d.ts +31 -0
- package/dist/runner/snapshot-source.js +122 -0
- package/dist/runner/vercel-sandbox-check.d.ts +2 -0
- package/dist/runner/vercel-sandbox-check.js +6 -2
- package/dist/runner/vercel-sandbox-options.d.ts +36 -6
- package/dist/runner/vercel-sandbox-options.js +62 -19
- package/dist/runner/vercel-sandbox-secrets.d.ts +55 -6
- package/dist/runner/vercel-sandbox-secrets.js +142 -9
- package/dist/sdk/extension/commands.d.ts +3 -8
- package/dist/sdk/extension/commands.js +1 -3
- package/package.json +4 -3
- package/skills/overview.md +1 -1
- package/dist/application.d.ts +0 -30
- package/dist/application.js +0 -41
- package/dist/bin/run.d.ts +0 -18
- package/dist/bin/run.js +0 -31
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
ENV_VAR_NAME_PATTERN,
|
|
4
4
|
ENV_VAR_NAME_RULE,
|
|
5
5
|
NOT_COUNTED,
|
|
6
|
+
SECRET_MIN_LENGTH,
|
|
6
7
|
booleanOption,
|
|
7
8
|
defaultResourceKey,
|
|
8
9
|
describeMintFailure,
|
|
@@ -22,7 +23,7 @@ import {
|
|
|
22
23
|
import {
|
|
23
24
|
defineErrors,
|
|
24
25
|
refused
|
|
25
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-24UYAK4R.js";
|
|
26
27
|
|
|
27
28
|
// src/runner/base.ts
|
|
28
29
|
async function resolveBase(checkout, request2) {
|
|
@@ -74,17 +75,17 @@ import { createHash } from "node:crypto";
|
|
|
74
75
|
var RUNNER_SNAPSHOTS_SUBPATH = ["runner", "snapshots"];
|
|
75
76
|
var SNAPSHOT_EXPIRATION_MS = 7 * 24 * 60 * 60 * 1e3;
|
|
76
77
|
var SNAPSHOT_MIN_REMAINING_MS = 60 * 60 * 1e3;
|
|
78
|
+
function sameRunnerTarget(a, b) {
|
|
79
|
+
return a.name === b.name && a.region === b.region && a.image === b.image;
|
|
80
|
+
}
|
|
81
|
+
function matchesRunnerTarget(entry, target) {
|
|
82
|
+
return sameRunnerTarget({ name: entry.runnerName, region: entry.region, image: entry.image }, target);
|
|
83
|
+
}
|
|
77
84
|
function snapshotEntryIdentity(entry) {
|
|
78
85
|
return createHash("sha256").update(
|
|
79
|
-
[
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
entry.region,
|
|
83
|
-
entry.runtime,
|
|
84
|
-
entry.runnerName,
|
|
85
|
-
entry.snapshotKey,
|
|
86
|
-
entry.base
|
|
87
|
-
].join("\0")
|
|
86
|
+
[entry.teamId, entry.projectId, entry.region, entry.image, entry.runnerName, entry.snapshotKey, entry.base].join(
|
|
87
|
+
"\0"
|
|
88
|
+
)
|
|
88
89
|
).digest("hex").slice(0, 32);
|
|
89
90
|
}
|
|
90
91
|
function snapshotEntryFileName(entry) {
|
|
@@ -120,9 +121,7 @@ async function resolveAncestorDistances(context, request2) {
|
|
|
120
121
|
const seen = /* @__PURE__ */ new Set([mergeBase]);
|
|
121
122
|
const distances = {};
|
|
122
123
|
for (const entry of entries) {
|
|
123
|
-
if (entry
|
|
124
|
-
continue;
|
|
125
|
-
}
|
|
124
|
+
if (!matchesRunnerTarget(entry, options)) continue;
|
|
126
125
|
if (isExpiredEntry(entry, now) || !hasTimeLeft(entry, now)) continue;
|
|
127
126
|
if (seen.has(entry.base)) continue;
|
|
128
127
|
seen.add(entry.base);
|
|
@@ -147,7 +146,7 @@ function classifySnapshotEntries(context, request2) {
|
|
|
147
146
|
verdicts.push({ kind: "rejected", entry, rejection });
|
|
148
147
|
};
|
|
149
148
|
for (const entry of entries) {
|
|
150
|
-
if (entry
|
|
149
|
+
if (!matchesRunnerTarget(entry, options)) {
|
|
151
150
|
verdicts.push({ kind: "other-runner", entry });
|
|
152
151
|
continue;
|
|
153
152
|
}
|
|
@@ -372,6 +371,9 @@ var SNAPSHOT_SETTLE_MS = 2 * 6e4;
|
|
|
372
371
|
var SANDBOX_CALL_LIMIT_MS = 3e4;
|
|
373
372
|
var KEEP_RUNNING_LIMIT_MS = 6e4;
|
|
374
373
|
function runnerSandboxScope(context, progress, settings) {
|
|
374
|
+
const managedCredentials = settings.managedCredentials ?? [];
|
|
375
|
+
if (managedCredentials.length > 0 && settings.keepMs > 0)
|
|
376
|
+
throw new Error("a sandbox scope with managedCredentials can't keep its runner sandbox");
|
|
375
377
|
const { runnerSandboxes: sandboxes, timer, clock } = context;
|
|
376
378
|
let phase = { kind: "open", sandboxes: /* @__PURE__ */ new Map(), creating: /* @__PURE__ */ new Set() };
|
|
377
379
|
const saving = /* @__PURE__ */ new Set();
|
|
@@ -568,9 +570,13 @@ function runnerSandboxScope(context, progress, settings) {
|
|
|
568
570
|
}
|
|
569
571
|
if (settings.signal.aborted) onSignal();
|
|
570
572
|
else settings.signal.addEventListener("abort", onSignal, { once: true });
|
|
573
|
+
const managed = managedCredentials.length === 0 ? {} : { managedCredentials };
|
|
571
574
|
return {
|
|
572
|
-
startBuildSandbox: (access, request2) => owned(() => sandboxes.startBuildSandbox(access, { ...request2, networkPolicy: settings.basePolicy })),
|
|
573
|
-
startRunnerSandbox: (access, request2) => owned(
|
|
575
|
+
startBuildSandbox: (access, request2) => owned(() => sandboxes.startBuildSandbox(access, { ...request2, networkPolicy: settings.basePolicy, ...managed })),
|
|
576
|
+
startRunnerSandbox: (access, request2) => owned(
|
|
577
|
+
() => sandboxes.startRunnerSandbox(access, { ...request2, networkPolicy: settings.basePolicy, ...managed }),
|
|
578
|
+
true
|
|
579
|
+
),
|
|
574
580
|
grantCredentials,
|
|
575
581
|
revokeCredentials,
|
|
576
582
|
saveSnapshot: (sandbox, request2) => track(
|
|
@@ -771,13 +777,139 @@ function describeOptionValue(value) {
|
|
|
771
777
|
if (typeof value === "object") return "an object";
|
|
772
778
|
return `a ${typeof value}`;
|
|
773
779
|
}
|
|
780
|
+
function isRecord(value) {
|
|
781
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
// src/runner/snapshot-source.ts
|
|
785
|
+
var SNAPSHOT_SOURCE_KEYS = /* @__PURE__ */ new Set(["kind", "remote"]);
|
|
786
|
+
var DEFAULT_REMOTE = "origin";
|
|
787
|
+
var REMOTE_NAME_PATTERN = /^[A-Za-z0-9_][A-Za-z0-9._/-]*$/;
|
|
788
|
+
function checkSnapshotSource(value, report) {
|
|
789
|
+
if (value === void 0) return void 0;
|
|
790
|
+
const path = ["snapshot", "source"];
|
|
791
|
+
if (!isRecord(value)) {
|
|
792
|
+
const actual = typeof value === "string" ? "a string" : describeOptionValue(value);
|
|
793
|
+
report(path, `must be { kind: "git-fetch", remote? }, not ${actual}`);
|
|
794
|
+
return false;
|
|
795
|
+
}
|
|
796
|
+
let ok = reportUnknownKeys(value, SNAPSHOT_SOURCE_KEYS, path, "a vercelSandbox snapshot source key", report);
|
|
797
|
+
const kind2 = value["kind"];
|
|
798
|
+
if (kind2 !== "git-fetch") {
|
|
799
|
+
report([...path, "kind"], `must be "git-fetch", not ${describeOptionValue(kind2)}`);
|
|
800
|
+
ok = false;
|
|
801
|
+
}
|
|
802
|
+
const remote = value["remote"] === void 0 ? DEFAULT_REMOTE : value["remote"];
|
|
803
|
+
if (typeof remote !== "string" || !REMOTE_NAME_PATTERN.test(remote)) {
|
|
804
|
+
const rule = 'must be a Git remote name such as "origin" (letters, digits, ".", "_", "-", and "/", starting with a letter, digit, or "_")';
|
|
805
|
+
report([...path, "remote"], typeof remote === "string" ? rule : `${rule}, not ${describeOptionValue(remote)}`);
|
|
806
|
+
ok = false;
|
|
807
|
+
}
|
|
808
|
+
return ok ? { kind: "git-fetch", remote } : false;
|
|
809
|
+
}
|
|
810
|
+
var UNSAFE_URL_CHARS = /[\s'"`$\\;|&<>(){}[\]*?!#~]/;
|
|
811
|
+
var SCHEME_URL_PATTERN = /^([A-Za-z][A-Za-z0-9+.-]*):\/\/([^/]*)(.*)$/;
|
|
812
|
+
var SCP_URL_PATTERN = /^(?:([^@/]*)@)?([^@/:]+):(.*)$/;
|
|
813
|
+
var HOST_PORT_PATTERN = /^([^:]+)(?::(\d{1,5}))?$/;
|
|
814
|
+
var HOST_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])?)+$/;
|
|
815
|
+
var CREDENTIALS_PROBLEM = "holds credentials; remove them from the remote URL and declare a sandbox credential in runner.credentials instead";
|
|
816
|
+
function normalizeGitFetchUrl(raw) {
|
|
817
|
+
if (raw.length === 0) return { ok: false, problem: "is empty" };
|
|
818
|
+
if (hasControlChar(raw) || UNSAFE_URL_CHARS.test(raw))
|
|
819
|
+
return { ok: false, problem: "holds whitespace, a control character, a quote, or a shell metacharacter" };
|
|
820
|
+
let https;
|
|
821
|
+
let userInfo2;
|
|
822
|
+
let hostPort;
|
|
823
|
+
let host;
|
|
824
|
+
let port;
|
|
825
|
+
let path;
|
|
826
|
+
const schemed = SCHEME_URL_PATTERN.exec(raw);
|
|
827
|
+
if (schemed !== null) {
|
|
828
|
+
const scheme = (schemed[1] ?? "").toLowerCase();
|
|
829
|
+
if (scheme !== "https" && scheme !== "ssh")
|
|
830
|
+
return { ok: false, problem: `uses ${scheme}://; git-fetch takes an HTTPS or SSH remote` };
|
|
831
|
+
https = scheme === "https";
|
|
832
|
+
const authority = schemed[2] ?? "";
|
|
833
|
+
const at = authority.lastIndexOf("@");
|
|
834
|
+
userInfo2 = at === -1 ? void 0 : authority.slice(0, at);
|
|
835
|
+
hostPort = at === -1 ? authority : authority.slice(at + 1);
|
|
836
|
+
host = "";
|
|
837
|
+
path = schemed[3] ?? "";
|
|
838
|
+
} else {
|
|
839
|
+
const scp = SCP_URL_PATTERN.exec(raw);
|
|
840
|
+
if (scp === null) return { ok: false, problem: "is not an HTTPS or SSH Git URL" };
|
|
841
|
+
https = false;
|
|
842
|
+
[, userInfo2, host = "", path = ""] = scp;
|
|
843
|
+
if (!path.startsWith("/")) path = `/${path}`;
|
|
844
|
+
}
|
|
845
|
+
if (userInfo2 !== void 0 && (https || userInfo2.includes(":") || userInfo2.includes("@")))
|
|
846
|
+
return { ok: false, problem: CREDENTIALS_PROBLEM };
|
|
847
|
+
if (hostPort !== void 0) {
|
|
848
|
+
const parsed = HOST_PORT_PATTERN.exec(hostPort);
|
|
849
|
+
if (parsed === null) return { ok: false, problem: "names no valid host or port" };
|
|
850
|
+
[, host = "", port] = parsed;
|
|
851
|
+
}
|
|
852
|
+
host = host.toLowerCase();
|
|
853
|
+
if (!HOST_PATTERN.test(host)) return { ok: false, problem: "names no valid host" };
|
|
854
|
+
if (port !== void 0 && (Number(port) < 1 || Number(port) > 65535))
|
|
855
|
+
return { ok: false, problem: "names no valid port" };
|
|
856
|
+
if (!isRepositoryPath(path)) return { ok: false, problem: "names no valid repository path" };
|
|
857
|
+
const httpsPort = https && port !== void 0 && Number(port) !== 443 ? `:${Number(port)}` : "";
|
|
858
|
+
return { ok: true, url: `https://${host}${httpsPort}${path}` };
|
|
859
|
+
}
|
|
860
|
+
function hasControlChar(value) {
|
|
861
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
862
|
+
const code = value.charCodeAt(index);
|
|
863
|
+
if (code <= 31 || code === 127) return true;
|
|
864
|
+
}
|
|
865
|
+
return false;
|
|
866
|
+
}
|
|
867
|
+
function isRepositoryPath(path) {
|
|
868
|
+
if (!path.startsWith("/") || path.includes("@") || path.includes(":")) return false;
|
|
869
|
+
return path.slice(1).split("/").every((segment) => segment.length > 0 && segment !== "." && segment !== "..");
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
// src/runner/gh.ts
|
|
873
|
+
var DEFAULT_GH_HOST = "github.com";
|
|
874
|
+
function resolveGhHost(source) {
|
|
875
|
+
return source.host ?? DEFAULT_GH_HOST;
|
|
876
|
+
}
|
|
877
|
+
function resolveGhFormat(domain, source) {
|
|
878
|
+
if (source.format !== void 0) return source.format;
|
|
879
|
+
return domain === resolveGhHost(source) ? "basic" : "bearer";
|
|
880
|
+
}
|
|
881
|
+
function ghBasicCredential(token) {
|
|
882
|
+
return Buffer.from(`x-access-token:${token}`, "utf8").toString("base64");
|
|
883
|
+
}
|
|
884
|
+
function frameGhToken(token, format) {
|
|
885
|
+
if (/[\r\n]/.test(token)) return { ok: false, problem: "multiline" };
|
|
886
|
+
if (/^(?:bearer|basic)\s/i.test(token)) return { ok: false, problem: "gh-preframed" };
|
|
887
|
+
if (token.length < SECRET_MIN_LENGTH) return { ok: false, problem: "short" };
|
|
888
|
+
if (format === "bearer") {
|
|
889
|
+
const headerValue2 = `Bearer ${token}`;
|
|
890
|
+
return { ok: true, headerValue: headerValue2, secrets: uniqueNonEmpty([headerValue2, token]) };
|
|
891
|
+
}
|
|
892
|
+
const basic = ghBasicCredential(token);
|
|
893
|
+
const headerValue = `Basic ${basic}`;
|
|
894
|
+
return { ok: true, headerValue, secrets: uniqueNonEmpty([headerValue, basic, token]) };
|
|
895
|
+
}
|
|
896
|
+
function ghEnvRedactionForms(raw) {
|
|
897
|
+
const basic = ghBasicCredential(raw);
|
|
898
|
+
return uniqueNonEmpty([`Basic ${basic}`, basic, `Bearer ${raw}`, raw]);
|
|
899
|
+
}
|
|
900
|
+
function uniqueNonEmpty(values) {
|
|
901
|
+
return [...new Set(values.filter((value) => value.length > 0))];
|
|
902
|
+
}
|
|
774
903
|
|
|
775
904
|
// src/runner/vercel-sandbox-secrets.ts
|
|
776
905
|
var CREDENTIAL_KEYS = /* @__PURE__ */ new Set(["domain", "header", "source", "requests"]);
|
|
906
|
+
var MANAGED_CREDENTIALS = /* @__PURE__ */ new Set(["npm"]);
|
|
907
|
+
var MANAGED_NPM_DOMAIN = "registry.npmjs.org";
|
|
777
908
|
var UNSAFE_SECRET_ENV_VAR_KEYS = /* @__PURE__ */ new Set(["name", "source"]);
|
|
778
909
|
var ENV_SOURCE_KEYS = /* @__PURE__ */ new Set(["kind", "name"]);
|
|
910
|
+
var GH_SOURCE_KEYS = /* @__PURE__ */ new Set(["kind", "env", "host", "format"]);
|
|
779
911
|
var DEFAULT_CREDENTIAL_HEADER = "authorization";
|
|
780
|
-
var
|
|
912
|
+
var HOST_PATTERN2 = /^(?=.{1,253}$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)+$/;
|
|
781
913
|
var HEADER_PATTERN = /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;
|
|
782
914
|
var REFUSED_HEADERS = /* @__PURE__ */ new Set(["host", "content-length", "transfer-encoding", "connection"]);
|
|
783
915
|
var RESERVED_UNSAFE_SECRET_ENV_VAR_NAMES = /* @__PURE__ */ new Set([
|
|
@@ -797,8 +929,66 @@ var RESERVED_UNSAFE_SECRET_ENV_VAR_NAMES = /* @__PURE__ */ new Set([
|
|
|
797
929
|
"NO_COLOR"
|
|
798
930
|
]);
|
|
799
931
|
var RESERVED_UNSAFE_SECRET_ENV_VAR_PREFIXES = ["LD_", "DYLD_"];
|
|
932
|
+
function sandboxCredentialSourceId(source) {
|
|
933
|
+
switch (source.kind) {
|
|
934
|
+
case "env":
|
|
935
|
+
return secretSourceId(source);
|
|
936
|
+
case "gh": {
|
|
937
|
+
const parts = ["gh"];
|
|
938
|
+
if (source.host !== void 0 && source.host !== DEFAULT_GH_HOST) parts.push(`host=${source.host}`);
|
|
939
|
+
if (source.env !== void 0) parts.push(`env=${source.env}`);
|
|
940
|
+
if (source.format !== void 0) parts.push(`format=${source.format}`);
|
|
941
|
+
return parts.join(":");
|
|
942
|
+
}
|
|
943
|
+
}
|
|
944
|
+
}
|
|
800
945
|
function credentialSourceIds(options) {
|
|
801
|
-
return [
|
|
946
|
+
return [
|
|
947
|
+
.../* @__PURE__ */ new Set([
|
|
948
|
+
...options.credentials.map(({ source }) => sandboxCredentialSourceId(source)),
|
|
949
|
+
...(options.managedCredentials ?? []).map((provider) => `managed:${provider}`)
|
|
950
|
+
])
|
|
951
|
+
].toSorted();
|
|
952
|
+
}
|
|
953
|
+
function checkManagedCredentials(value, credentials2, report) {
|
|
954
|
+
if (value === void 0) return [];
|
|
955
|
+
if (!Array.isArray(value)) {
|
|
956
|
+
report(
|
|
957
|
+
["managedCredentials"],
|
|
958
|
+
`must be a list of Vercel-managed credentials, such as ["npm"], not ${describeOptionValue(value)}`
|
|
959
|
+
);
|
|
960
|
+
return void 0;
|
|
961
|
+
}
|
|
962
|
+
let ok = true;
|
|
963
|
+
const checked = [];
|
|
964
|
+
const seen = /* @__PURE__ */ new Set();
|
|
965
|
+
value.forEach((entry, index) => {
|
|
966
|
+
const path = ["managedCredentials", String(index)];
|
|
967
|
+
if (typeof entry !== "string" || !MANAGED_CREDENTIALS.has(entry)) {
|
|
968
|
+
report(path, `must be "npm", not ${describeOptionValue(entry)}`);
|
|
969
|
+
ok = false;
|
|
970
|
+
return;
|
|
971
|
+
}
|
|
972
|
+
if (seen.has(entry)) {
|
|
973
|
+
report(path, `names ${entry} again`);
|
|
974
|
+
ok = false;
|
|
975
|
+
return;
|
|
976
|
+
}
|
|
977
|
+
seen.add(entry);
|
|
978
|
+
checked.push(entry);
|
|
979
|
+
});
|
|
980
|
+
if (checked.includes("npm") && credentials2 !== void 0) {
|
|
981
|
+
credentials2.forEach((credential, index) => {
|
|
982
|
+
if (credential.domain === MANAGED_NPM_DOMAIN && credential.header === DEFAULT_CREDENTIAL_HEADER) {
|
|
983
|
+
report(
|
|
984
|
+
["credentials", String(index)],
|
|
985
|
+
`can't set ${DEFAULT_CREDENTIAL_HEADER} on ${MANAGED_NPM_DOMAIN} when runner.managedCredentials includes "npm": a sandbox credential on ${MANAGED_NPM_DOMAIN} overrides the Vercel-managed npm token`
|
|
986
|
+
);
|
|
987
|
+
ok = false;
|
|
988
|
+
}
|
|
989
|
+
});
|
|
990
|
+
}
|
|
991
|
+
return ok ? checked : void 0;
|
|
802
992
|
}
|
|
803
993
|
function checkCredentials(value, report) {
|
|
804
994
|
if (value === void 0) return [];
|
|
@@ -849,7 +1039,7 @@ function checkCredential(value, path, report) {
|
|
|
849
1039
|
}
|
|
850
1040
|
let ok = reportUnknownKeys(value, CREDENTIAL_KEYS, path, "a credential key", report);
|
|
851
1041
|
const domain = value["domain"];
|
|
852
|
-
if (typeof domain !== "string" || !
|
|
1042
|
+
if (typeof domain !== "string" || !HOST_PATTERN2.test(domain)) {
|
|
853
1043
|
report(
|
|
854
1044
|
[...path, "domain"],
|
|
855
1045
|
`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)}`
|
|
@@ -857,18 +1047,25 @@ function checkCredential(value, path, report) {
|
|
|
857
1047
|
ok = false;
|
|
858
1048
|
}
|
|
859
1049
|
const header = value["header"] === void 0 ? DEFAULT_CREDENTIAL_HEADER : value["header"];
|
|
1050
|
+
let headerValid = true;
|
|
860
1051
|
if (typeof header !== "string" || !HEADER_PATTERN.test(header)) {
|
|
861
1052
|
report(
|
|
862
1053
|
[...path, "header"],
|
|
863
1054
|
`must be an HTTP header name, such as authorization, not ${describeOptionValue(header)}`
|
|
864
1055
|
);
|
|
865
1056
|
ok = false;
|
|
1057
|
+
headerValid = false;
|
|
866
1058
|
} else if (REFUSED_HEADERS.has(header.toLowerCase())) {
|
|
867
1059
|
report([...path, "header"], `can't be ${header}: the firewall or HTTP sets it`);
|
|
868
1060
|
ok = false;
|
|
1061
|
+
headerValid = false;
|
|
869
1062
|
}
|
|
870
|
-
const source =
|
|
1063
|
+
const source = checkSandboxCredentialSource(value["source"], [...path, "source"], report);
|
|
871
1064
|
if (source === void 0) ok = false;
|
|
1065
|
+
else if (headerValid && source.kind === "gh" && header.toLowerCase() !== DEFAULT_CREDENTIAL_HEADER) {
|
|
1066
|
+
report([...path, "header"], `can't be ${header}: a gh credential always sets the authorization header`);
|
|
1067
|
+
ok = false;
|
|
1068
|
+
}
|
|
872
1069
|
const requests = value["requests"] === void 0 ? "read" : value["requests"];
|
|
873
1070
|
if (requests !== "read" && requests !== "all") {
|
|
874
1071
|
report([...path, "requests"], `must be "read" or "all", not ${describeOptionValue(requests)}`);
|
|
@@ -881,6 +1078,52 @@ function checkCredential(value, path, report) {
|
|
|
881
1078
|
requests
|
|
882
1079
|
} : void 0;
|
|
883
1080
|
}
|
|
1081
|
+
function checkSandboxCredentialSource(value, path, report) {
|
|
1082
|
+
if (!isPlainObject(value)) {
|
|
1083
|
+
report(
|
|
1084
|
+
path,
|
|
1085
|
+
`must be a sandbox credential source, { kind: "env", name } or { kind: "gh", env?, host?, format? }, not ${describeOptionValue(value)}`
|
|
1086
|
+
);
|
|
1087
|
+
return void 0;
|
|
1088
|
+
}
|
|
1089
|
+
const kind2 = value["kind"];
|
|
1090
|
+
if (kind2 === "env") {
|
|
1091
|
+
return checkEnvSecretSource(value, path, report);
|
|
1092
|
+
}
|
|
1093
|
+
if (kind2 === "gh") {
|
|
1094
|
+
return checkGhCredentialSource(value, path, report);
|
|
1095
|
+
}
|
|
1096
|
+
report([...path, "kind"], `must be "env" or "gh", not ${describeOptionValue(kind2)}`);
|
|
1097
|
+
return void 0;
|
|
1098
|
+
}
|
|
1099
|
+
function checkGhCredentialSource(value, path, report) {
|
|
1100
|
+
let ok = reportUnknownKeys(value, GH_SOURCE_KEYS, path, "a sandbox credential source key", report);
|
|
1101
|
+
const env = value["env"];
|
|
1102
|
+
if (env !== void 0 && (typeof env !== "string" || !ENV_VAR_NAME_PATTERN.test(env))) {
|
|
1103
|
+
report([...path, "env"], `must be ${ENV_VAR_NAME_RULE}, not ${describeOptionValue(env)}`);
|
|
1104
|
+
ok = false;
|
|
1105
|
+
}
|
|
1106
|
+
const host = value["host"];
|
|
1107
|
+
if (host !== void 0 && (typeof host !== "string" || !HOST_PATTERN2.test(host))) {
|
|
1108
|
+
report(
|
|
1109
|
+
[...path, "host"],
|
|
1110
|
+
`must be a bare hostname, such as github.com: lowercase letters, digits, dots, and hyphens, with at least one dot, and no scheme, port, path, or wildcard, not ${describeOptionValue(host)}`
|
|
1111
|
+
);
|
|
1112
|
+
ok = false;
|
|
1113
|
+
}
|
|
1114
|
+
const format = value["format"];
|
|
1115
|
+
if (format !== void 0 && format !== "basic" && format !== "bearer") {
|
|
1116
|
+
report([...path, "format"], `must be "basic" or "bearer", not ${describeOptionValue(format)}`);
|
|
1117
|
+
ok = false;
|
|
1118
|
+
}
|
|
1119
|
+
if (!ok) return void 0;
|
|
1120
|
+
return {
|
|
1121
|
+
kind: "gh",
|
|
1122
|
+
...env === void 0 ? {} : { env },
|
|
1123
|
+
...host === void 0 ? {} : { host },
|
|
1124
|
+
...format === void 0 ? {} : { format }
|
|
1125
|
+
};
|
|
1126
|
+
}
|
|
884
1127
|
function checkSecretSource(value, path, report) {
|
|
885
1128
|
if (!isPlainObject(value)) {
|
|
886
1129
|
report(path, `must be a secret source, { kind: "env", name }, not ${describeOptionValue(value)}`);
|
|
@@ -891,7 +1134,10 @@ function checkSecretSource(value, path, report) {
|
|
|
891
1134
|
report([...path, "kind"], `must be "env", not ${describeOptionValue(kind2)}`);
|
|
892
1135
|
if (kind2 !== void 0) return void 0;
|
|
893
1136
|
}
|
|
894
|
-
|
|
1137
|
+
return checkEnvSecretSource(value, path, report, kind2 === "env");
|
|
1138
|
+
}
|
|
1139
|
+
function checkEnvSecretSource(value, path, report, kindOk = true) {
|
|
1140
|
+
let ok = kindOk;
|
|
895
1141
|
if (!reportUnknownKeys(value, ENV_SOURCE_KEYS, path, "a secret source key", report)) ok = false;
|
|
896
1142
|
const name = value["name"];
|
|
897
1143
|
if (typeof name !== "string" || !ENV_VAR_NAME_PATTERN.test(name)) {
|
|
@@ -912,7 +1158,16 @@ function checkUnsafeSecretEnvVars(value, env, credentials2, report) {
|
|
|
912
1158
|
let ok = true;
|
|
913
1159
|
const checked = [];
|
|
914
1160
|
const seen = /* @__PURE__ */ new Set();
|
|
915
|
-
const
|
|
1161
|
+
const credentialEnvSources = new Set(
|
|
1162
|
+
(credentials2 ?? []).flatMap(({ source }) => {
|
|
1163
|
+
switch (source.kind) {
|
|
1164
|
+
case "env":
|
|
1165
|
+
return [secretSourceId(source)];
|
|
1166
|
+
case "gh":
|
|
1167
|
+
return source.env === void 0 ? [] : [`env:${source.env}`];
|
|
1168
|
+
}
|
|
1169
|
+
})
|
|
1170
|
+
);
|
|
916
1171
|
value.forEach((entry, index) => {
|
|
917
1172
|
const path = ["unsafeSecretEnvVars", String(index)];
|
|
918
1173
|
if (!isPlainObject(entry)) {
|
|
@@ -955,7 +1210,7 @@ function checkUnsafeSecretEnvVars(value, env, credentials2, report) {
|
|
|
955
1210
|
const source = checkSecretSource(entry["source"], [...path, "source"], report);
|
|
956
1211
|
if (source === void 0) {
|
|
957
1212
|
entryOk = false;
|
|
958
|
-
} else if (
|
|
1213
|
+
} else if (credentialEnvSources.has(secretSourceId(source))) {
|
|
959
1214
|
report([...path, "source"], `can't use ${secretSourceId(source)}: runner.credentials already reads it`);
|
|
960
1215
|
entryOk = false;
|
|
961
1216
|
}
|
|
@@ -980,7 +1235,7 @@ var VERCEL_SANDBOX_DEFAULTS = {
|
|
|
980
1235
|
timeout: "60m",
|
|
981
1236
|
baseRefs: ["main", "origin/main"],
|
|
982
1237
|
region: "iad1",
|
|
983
|
-
|
|
1238
|
+
image: "vercel/sandbox/node:al-24"
|
|
984
1239
|
};
|
|
985
1240
|
var VERCEL_SANDBOX_OPTION_KEYS = /* @__PURE__ */ new Set([
|
|
986
1241
|
"name",
|
|
@@ -990,23 +1245,27 @@ var VERCEL_SANDBOX_OPTION_KEYS = /* @__PURE__ */ new Set([
|
|
|
990
1245
|
"vcpus",
|
|
991
1246
|
"env",
|
|
992
1247
|
"credentials",
|
|
1248
|
+
"managedCredentials",
|
|
993
1249
|
"unsafeSecretEnvVars",
|
|
994
1250
|
"allowedDomains",
|
|
995
1251
|
"timeout",
|
|
996
1252
|
"keepSandbox",
|
|
997
1253
|
"baseRefs",
|
|
998
1254
|
"region",
|
|
999
|
-
"
|
|
1255
|
+
"image",
|
|
1000
1256
|
"sandboxes"
|
|
1001
1257
|
]);
|
|
1002
1258
|
var SANDBOXES_KEYS = /* @__PURE__ */ new Set(["max", "default"]);
|
|
1003
1259
|
var SANDBOXES_DEFAULT_RULE_KEYS = /* @__PURE__ */ new Set(["filesPerSandbox", "max"]);
|
|
1004
1260
|
var VCPUS_RULE_KEYS = /* @__PURE__ */ new Set(["resource", "option", "per", "min", "max"]);
|
|
1005
|
-
var SNAPSHOT_KEYS = /* @__PURE__ */ new Set(["vcpus", "summary", "toolchains", "prebuild"]);
|
|
1261
|
+
var SNAPSHOT_KEYS = /* @__PURE__ */ new Set(["vcpus", "summary", "source", "toolchains", "prebuild"]);
|
|
1006
1262
|
var RUN_KEYS = /* @__PURE__ */ new Set(["install", "build"]);
|
|
1007
1263
|
var STEP_KEYS = /* @__PURE__ */ new Set(["label", "script"]);
|
|
1008
1264
|
var TOOLCHAIN_STEP_KEYS = /* @__PURE__ */ new Set(["label", "script", "baseFiles"]);
|
|
1009
1265
|
var NAME_PATTERN = /^[a-z0-9][a-z0-9-]*$/;
|
|
1266
|
+
var VCR_HOST_PREFIX = "vcr.vercel.com/";
|
|
1267
|
+
var MANAGED_IMAGE_PREFIX = "vercel/sandbox/";
|
|
1268
|
+
var IMAGE_DIGEST_PATTERN = /^sha256:[0-9a-f]{64}$/;
|
|
1010
1269
|
var 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])?)+$/;
|
|
1011
1270
|
function checkVercelSandboxOptions(value) {
|
|
1012
1271
|
const problems = [];
|
|
@@ -1030,6 +1289,7 @@ function checkVercelSandboxOptions(value) {
|
|
|
1030
1289
|
const vcpus = checkVcpus(value["vcpus"], report);
|
|
1031
1290
|
const env = checkEnv(value["env"], report);
|
|
1032
1291
|
const credentials2 = checkCredentials(value["credentials"], report);
|
|
1292
|
+
const managedCredentials = checkManagedCredentials(value["managedCredentials"], credentials2, report);
|
|
1033
1293
|
const unsafeSecretEnvVars = checkUnsafeSecretEnvVars(value["unsafeSecretEnvVars"], env, credentials2, report);
|
|
1034
1294
|
const allowedDomains = checkAllowedDomains(value["allowedDomains"], report);
|
|
1035
1295
|
const timeout = orDefault(value["timeout"], VERCEL_SANDBOX_DEFAULTS.timeout);
|
|
@@ -1046,19 +1306,24 @@ function checkVercelSandboxOptions(value) {
|
|
|
1046
1306
|
["keepSandbox"],
|
|
1047
1307
|
`must be 0, or a whole number of minutes or hours up to 5h, not ${describeOptionValue(keepSandbox)}`
|
|
1048
1308
|
);
|
|
1049
|
-
else if (
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1309
|
+
else if (keepSandboxMinutes !== void 0 && keepSandboxMinutes > 0) {
|
|
1310
|
+
if (unsafeSecretEnvVars !== void 0 && unsafeSecretEnvVars.length > 0)
|
|
1311
|
+
report(
|
|
1312
|
+
["keepSandbox"],
|
|
1313
|
+
"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"
|
|
1314
|
+
);
|
|
1315
|
+
if (managedCredentials !== void 0 && managedCredentials.length > 0)
|
|
1316
|
+
report(
|
|
1317
|
+
["keepSandbox"],
|
|
1318
|
+
"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"
|
|
1319
|
+
);
|
|
1320
|
+
}
|
|
1054
1321
|
const baseRefs = checkBaseRefs(value["baseRefs"], report);
|
|
1055
1322
|
const region = orDefault(value["region"], VERCEL_SANDBOX_DEFAULTS.region);
|
|
1056
1323
|
if (!isNonEmptyString(region)) report(["region"], `must be a non-empty string, not ${describeOptionValue(region)}`);
|
|
1057
|
-
const
|
|
1058
|
-
if (!isNonEmptyString(runtime))
|
|
1059
|
-
report(["runtime"], `must be a non-empty string, not ${describeOptionValue(runtime)}`);
|
|
1324
|
+
const image = checkImage(orDefault(value["image"], VERCEL_SANDBOX_DEFAULTS.image), report);
|
|
1060
1325
|
const sandboxes = checkSandboxes(value["sandboxes"], report);
|
|
1061
|
-
if (problems.length > 0 || snapshot === void 0 || run === void 0 || vcpus === void 0 || env === void 0 || credentials2 === void 0 || unsafeSecretEnvVars === void 0 || allowedDomains === null || baseRefs === void 0 || timeoutMinutes === void 0 || sandboxes === false)
|
|
1326
|
+
if (problems.length > 0 || snapshot === void 0 || run === void 0 || vcpus === void 0 || env === void 0 || credentials2 === void 0 || managedCredentials === void 0 || unsafeSecretEnvVars === void 0 || allowedDomains === null || baseRefs === void 0 || timeoutMinutes === void 0 || image === void 0 || sandboxes === false)
|
|
1062
1327
|
return { ok: false, problems };
|
|
1063
1328
|
return {
|
|
1064
1329
|
ok: true,
|
|
@@ -1070,6 +1335,7 @@ function checkVercelSandboxOptions(value) {
|
|
|
1070
1335
|
vcpus,
|
|
1071
1336
|
env,
|
|
1072
1337
|
credentials: credentials2,
|
|
1338
|
+
managedCredentials,
|
|
1073
1339
|
unsafeSecretEnvVars,
|
|
1074
1340
|
...allowedDomains === void 0 ? {} : { allowedDomains },
|
|
1075
1341
|
timeout,
|
|
@@ -1077,11 +1343,47 @@ function checkVercelSandboxOptions(value) {
|
|
|
1077
1343
|
keepSandboxMinutes,
|
|
1078
1344
|
baseRefs,
|
|
1079
1345
|
region,
|
|
1080
|
-
|
|
1346
|
+
image,
|
|
1081
1347
|
...sandboxes === void 0 ? {} : { sandboxes }
|
|
1082
1348
|
}
|
|
1083
1349
|
};
|
|
1084
1350
|
}
|
|
1351
|
+
function checkImage(value, report) {
|
|
1352
|
+
if (!isNonEmptyString(value)) {
|
|
1353
|
+
report(["image"], `must be a non-empty string, not ${describeOptionValue(value)}`);
|
|
1354
|
+
return void 0;
|
|
1355
|
+
}
|
|
1356
|
+
if (/\s/.test(value)) {
|
|
1357
|
+
report(["image"], `must be an image reference with no whitespace, not ${describeOptionValue(value)}`);
|
|
1358
|
+
return void 0;
|
|
1359
|
+
}
|
|
1360
|
+
const at = value.indexOf("@");
|
|
1361
|
+
const name = at === -1 ? value : value.slice(0, at);
|
|
1362
|
+
const digest = at === -1 ? void 0 : value.slice(at + 1);
|
|
1363
|
+
if (digest !== void 0 && (name === "" || !IMAGE_DIGEST_PATTERN.test(digest))) {
|
|
1364
|
+
report(
|
|
1365
|
+
["image"],
|
|
1366
|
+
`must be "<repository>@sha256:<64 lowercase hex characters>" when it names a digest, not ${describeOptionValue(value)}`
|
|
1367
|
+
);
|
|
1368
|
+
return void 0;
|
|
1369
|
+
}
|
|
1370
|
+
const repo = name.startsWith(VCR_HOST_PREFIX) ? name.slice(VCR_HOST_PREFIX.length) : name;
|
|
1371
|
+
if (repo === MANAGED_IMAGE_PREFIX) {
|
|
1372
|
+
report(
|
|
1373
|
+
["image"],
|
|
1374
|
+
`must name a Vercel-managed image after "${MANAGED_IMAGE_PREFIX}", not ${describeOptionValue(value)}`
|
|
1375
|
+
);
|
|
1376
|
+
return void 0;
|
|
1377
|
+
}
|
|
1378
|
+
if (digest === void 0 && !repo.startsWith(MANAGED_IMAGE_PREFIX)) {
|
|
1379
|
+
report(
|
|
1380
|
+
["image"],
|
|
1381
|
+
`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)}`
|
|
1382
|
+
);
|
|
1383
|
+
return void 0;
|
|
1384
|
+
}
|
|
1385
|
+
return value;
|
|
1386
|
+
}
|
|
1085
1387
|
function checkVcpus(value, report) {
|
|
1086
1388
|
if (isPositiveInteger(value)) return value;
|
|
1087
1389
|
if (typeof value === "function") {
|
|
@@ -1224,12 +1526,14 @@ function checkSnapshot(value, report) {
|
|
|
1224
1526
|
report(["snapshot", "summary"], `must be a non-empty string, not ${describeOptionValue(summary)}`);
|
|
1225
1527
|
ok = false;
|
|
1226
1528
|
}
|
|
1529
|
+
const source = checkSnapshotSource(value["source"], report);
|
|
1227
1530
|
const toolchains = checkSteps(value["toolchains"], ["snapshot", "toolchains"], true, report);
|
|
1228
1531
|
const prebuild = checkSteps(value["prebuild"], ["snapshot", "prebuild"], false, report);
|
|
1229
|
-
if (!ok || toolchains === void 0 || prebuild === void 0) return void 0;
|
|
1532
|
+
if (!ok || source === false || toolchains === void 0 || prebuild === void 0) return void 0;
|
|
1230
1533
|
return {
|
|
1231
1534
|
vcpus,
|
|
1232
1535
|
...summary === void 0 ? {} : { summary },
|
|
1536
|
+
...source === void 0 ? {} : { source },
|
|
1233
1537
|
toolchains,
|
|
1234
1538
|
prebuild
|
|
1235
1539
|
};
|
|
@@ -1424,9 +1728,6 @@ function resolveSandboxCountDefault(sandboxesDefault, testPlan) {
|
|
|
1424
1728
|
function orDefault(value, fallback) {
|
|
1425
1729
|
return value === void 0 ? fallback : value;
|
|
1426
1730
|
}
|
|
1427
|
-
function isRecord(value) {
|
|
1428
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1429
|
-
}
|
|
1430
1731
|
function isNonEmptyString(value) {
|
|
1431
1732
|
return typeof value === "string" && value.length > 0;
|
|
1432
1733
|
}
|
|
@@ -1444,7 +1745,7 @@ function isRelativeFilePath(value) {
|
|
|
1444
1745
|
}
|
|
1445
1746
|
|
|
1446
1747
|
// src/runner/snapshot-key.ts
|
|
1447
|
-
var SNAPSHOT_FORMAT =
|
|
1748
|
+
var SNAPSHOT_FORMAT = 6;
|
|
1448
1749
|
var SANDBOX_ROOT = "/vercel/sandbox";
|
|
1449
1750
|
var STAGED_FILES = {
|
|
1450
1751
|
baseTarball: "base.tgz",
|
|
@@ -1454,6 +1755,9 @@ var STAGED_FILES = {
|
|
|
1454
1755
|
untrackedFileList: "untracked-files"
|
|
1455
1756
|
};
|
|
1456
1757
|
var GIT_IDENTITY = "-c user.email=storm-runner@vercel.invalid -c user.name='storm runner' -c commit.gpgsign=false";
|
|
1758
|
+
function shellQuote(value) {
|
|
1759
|
+
return `'${value.replaceAll("'", "'\\''")}'`;
|
|
1760
|
+
}
|
|
1457
1761
|
function bashScript(lines, root = SANDBOX_ROOT) {
|
|
1458
1762
|
return ["set -euo pipefail", `cd ${root}`, ...lines].join("\n");
|
|
1459
1763
|
}
|
|
@@ -1469,6 +1773,16 @@ function baseIndexScript(base, staging) {
|
|
|
1469
1773
|
`git ${GIT_IDENTITY} commit -q --no-verify -m 'base ${base}'`
|
|
1470
1774
|
]);
|
|
1471
1775
|
}
|
|
1776
|
+
function gitFetchBaseIndexScript(url, base, root = SANDBOX_ROOT) {
|
|
1777
|
+
return bashScript(
|
|
1778
|
+
[
|
|
1779
|
+
"git -c init.defaultBranch=main init -q",
|
|
1780
|
+
`GIT_TERMINAL_PROMPT=0 git -c credential.helper= -c core.autocrlf=false -c core.eol=lf fetch --depth 1 --no-tags -- ${shellQuote(url)} ${shellQuote(base)}`,
|
|
1781
|
+
"git -c core.autocrlf=false -c core.eol=lf checkout --detach --force FETCH_HEAD"
|
|
1782
|
+
],
|
|
1783
|
+
root
|
|
1784
|
+
);
|
|
1785
|
+
}
|
|
1472
1786
|
function applyScript(staging, root = SANDBOX_ROOT) {
|
|
1473
1787
|
const patch = `${staging}/${STAGED_FILES.patch}`;
|
|
1474
1788
|
const tarball = `${staging}/${STAGED_FILES.untrackedTarball}`;
|
|
@@ -1501,7 +1815,7 @@ function snapshotKey(steps) {
|
|
|
1501
1815
|
`baseFiles=${baseFiles.length}`,
|
|
1502
1816
|
...baseFiles.flatMap(({ path, text: content }) => [path, content]),
|
|
1503
1817
|
...text(steps.toolchains),
|
|
1504
|
-
baseIndexScript("<base>", "<staging>"),
|
|
1818
|
+
steps.source === void 0 ? baseIndexScript("<base>", "<staging>") : gitFetchBaseIndexScript("<url>", "<base>"),
|
|
1505
1819
|
...text(steps.prebuild)
|
|
1506
1820
|
].join("\0")
|
|
1507
1821
|
).digest("hex");
|
|
@@ -1535,7 +1849,8 @@ async function snapshotInputsAt(checkout, request2) {
|
|
|
1535
1849
|
credentials: credentialSourceIds(options),
|
|
1536
1850
|
baseFiles,
|
|
1537
1851
|
toolchains: snapshot.toolchains,
|
|
1538
|
-
prebuild: snapshot.prebuild
|
|
1852
|
+
prebuild: snapshot.prebuild,
|
|
1853
|
+
source: snapshot.source
|
|
1539
1854
|
})
|
|
1540
1855
|
};
|
|
1541
1856
|
}
|
|
@@ -1676,16 +1991,23 @@ async function buildSnapshot(context, request2, control, progress) {
|
|
|
1676
1991
|
why: request2.why,
|
|
1677
1992
|
summary: options.snapshot.summary ?? [...options.snapshot.toolchains, ...options.snapshot.prebuild].map(({ label }) => label).join(", ")
|
|
1678
1993
|
});
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1994
|
+
let fetchUrl;
|
|
1995
|
+
if (options.snapshot.source !== void 0) {
|
|
1996
|
+
const resolved = await resolveGitFetchUrl(context.checkout, {
|
|
1997
|
+
repoRoot,
|
|
1998
|
+
remote: options.snapshot.source.remote
|
|
1999
|
+
});
|
|
2000
|
+
if (!resolved.ok) return { kind: "failed", failure: { kind: "checkout-failed", failure: resolved.failure } };
|
|
2001
|
+
fetchUrl = resolved.value;
|
|
2002
|
+
}
|
|
2003
|
+
const startBuild = () => scope.startBuildSandbox(access, {
|
|
2004
|
+
region: options.region,
|
|
2005
|
+
image: options.image,
|
|
2006
|
+
vcpus: options.snapshot.vcpus,
|
|
2007
|
+
timeoutMs: BUILD_SANDBOX_TIMEOUT_MS,
|
|
2008
|
+
...publish === void 0 ? { tags: runnerTags(options.name, "snapshot-build", request2.user) } : { name: publish.name, tags: publish.tags }
|
|
2009
|
+
});
|
|
2010
|
+
const [started, baseStep] = fetchUrl === void 0 ? await Promise.all([startBuild(), context.checkout.baseArchive({ repoRoot, base })]) : [await startBuild(), fetchUrl];
|
|
1689
2011
|
if (!started.ok)
|
|
1690
2012
|
return started.failure.kind === "name-taken" ? { kind: "name-taken", name: started.failure.name, message: started.failure.message } : sandboxStop("start-build-sandbox", started.failure);
|
|
1691
2013
|
const sandbox = started.value;
|
|
@@ -1697,16 +2019,22 @@ async function buildSnapshot(context, request2, control, progress) {
|
|
|
1697
2019
|
vcpus: options.snapshot.vcpus,
|
|
1698
2020
|
ms: now() - startedAt
|
|
1699
2021
|
});
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
2022
|
+
let baseStepScript;
|
|
2023
|
+
if (typeof baseStep === "string") {
|
|
2024
|
+
baseStepScript = gitFetchBaseIndexScript(baseStep, base);
|
|
2025
|
+
} else {
|
|
2026
|
+
if (!baseStep.ok) return { kind: "failed", failure: { kind: "checkout-failed", failure: baseStep.failure } };
|
|
2027
|
+
const staged = await context.runnerSandboxes.upload(
|
|
2028
|
+
sandbox,
|
|
2029
|
+
[
|
|
2030
|
+
{ name: STAGED_FILES.baseTarball, content: baseStep.value.tarball },
|
|
2031
|
+
{ name: STAGED_FILES.baseFileList, content: baseStep.value.fileList }
|
|
2032
|
+
],
|
|
2033
|
+
signal
|
|
2034
|
+
);
|
|
2035
|
+
if (!staged.ok) return sandboxStop("upload", staged.failure);
|
|
2036
|
+
baseStepScript = baseIndexScript(base, staged.value.directory);
|
|
2037
|
+
}
|
|
1710
2038
|
if (prepared.baseFiles.length > 0) {
|
|
1711
2039
|
const encoder = new TextEncoder();
|
|
1712
2040
|
const placed = await context.runnerSandboxes.placeBaseFiles(
|
|
@@ -1718,7 +2046,7 @@ async function buildSnapshot(context, request2, control, progress) {
|
|
|
1718
2046
|
}
|
|
1719
2047
|
const steps = [
|
|
1720
2048
|
...options.snapshot.toolchains,
|
|
1721
|
-
{ label: BASE_INDEX_LABEL, script:
|
|
2049
|
+
{ label: BASE_INDEX_LABEL, script: baseStepScript },
|
|
1722
2050
|
...options.snapshot.prebuild
|
|
1723
2051
|
];
|
|
1724
2052
|
await progress.emit({ kind: "output-started", section: "snapshot", sandbox: sandbox.name, region: options.region });
|
|
@@ -1766,7 +2094,7 @@ async function buildSnapshot(context, request2, control, progress) {
|
|
|
1766
2094
|
teamId: access.teamId,
|
|
1767
2095
|
projectId: access.projectId,
|
|
1768
2096
|
region: options.region,
|
|
1769
|
-
|
|
2097
|
+
image: options.image,
|
|
1770
2098
|
runnerName: options.name,
|
|
1771
2099
|
snapshotKey: prepared.snapshotKey,
|
|
1772
2100
|
base,
|
|
@@ -1790,6 +2118,13 @@ async function buildSnapshot(context, request2, control, progress) {
|
|
|
1790
2118
|
value: { entry, ms, sizeBytes: saved.value.sizeBytes, localIndexFailure: written.ok ? null : written.failure }
|
|
1791
2119
|
};
|
|
1792
2120
|
}
|
|
2121
|
+
async function resolveGitFetchUrl(checkout, request2) {
|
|
2122
|
+
const remote = await checkout.remoteUrl(request2);
|
|
2123
|
+
if (!remote.ok) return remote;
|
|
2124
|
+
const fetchUrl = normalizeGitFetchUrl(remote.value);
|
|
2125
|
+
if (fetchUrl.ok) return { ok: true, value: fetchUrl.url };
|
|
2126
|
+
return { ok: false, failure: { message: `the URL of Git remote "${request2.remote}" ${fetchUrl.problem}` } };
|
|
2127
|
+
}
|
|
1793
2128
|
|
|
1794
2129
|
// src/runner/shared-snapshot-entry.ts
|
|
1795
2130
|
import { createHash as createHash3 } from "node:crypto";
|
|
@@ -1813,9 +2148,7 @@ function hasSnapshotId(row) {
|
|
|
1813
2148
|
return row.currentSnapshotId !== void 0 && row.currentSnapshotId !== "";
|
|
1814
2149
|
}
|
|
1815
2150
|
function sharedSnapshotBucket(input) {
|
|
1816
|
-
return createHash3("sha256").update(
|
|
1817
|
-
[input.teamId, input.projectId, input.region, input.runtime, input.runnerName, input.snapshotKey].join("\0")
|
|
1818
|
-
).digest("hex").slice(0, 16);
|
|
2151
|
+
return createHash3("sha256").update([input.teamId, input.projectId, input.region, input.image, input.runnerName, input.snapshotKey].join("\0")).digest("hex").slice(0, 16);
|
|
1819
2152
|
}
|
|
1820
2153
|
function sharedSnapshotSandboxPrefix(bucket) {
|
|
1821
2154
|
return `${SHARED_SNAPSHOT_SANDBOX_PREFIX}${bucket}-`;
|
|
@@ -1888,7 +2221,7 @@ function usableSharedEntry(access, runner, snapshotKey2, base, sandbox, snapshot
|
|
|
1888
2221
|
teamId: access.teamId,
|
|
1889
2222
|
projectId: access.projectId,
|
|
1890
2223
|
region: runner.region,
|
|
1891
|
-
|
|
2224
|
+
image: runner.image,
|
|
1892
2225
|
runnerName: runner.name,
|
|
1893
2226
|
snapshotKey: snapshotKey2,
|
|
1894
2227
|
base,
|
|
@@ -1947,7 +2280,7 @@ async function prepareSnapshotBuild(context, request2) {
|
|
|
1947
2280
|
const listed = await context.runnerSnapshots.listEntries();
|
|
1948
2281
|
const now = context.clock.now();
|
|
1949
2282
|
const indexed = (listed.ok ? listed.value.entries : []).filter(
|
|
1950
|
-
(entry) => entry.base === base && entry
|
|
2283
|
+
(entry) => entry.base === base && matchesRunnerTarget(entry, options) && entry.snapshotKey === inputs.key && hasTimeLeft(entry, now)
|
|
1951
2284
|
);
|
|
1952
2285
|
const atMergeBase = base === mergeBase?.commit;
|
|
1953
2286
|
let commitsAfterBase = null;
|
|
@@ -1983,11 +2316,15 @@ async function prepareSnapshotBuild(context, request2) {
|
|
|
1983
2316
|
}
|
|
1984
2317
|
};
|
|
1985
2318
|
}
|
|
2319
|
+
function sameSnapshotBuild(a, b) {
|
|
2320
|
+
return sameRunnerTarget(a.options, b.options) && a.snapshotKey === b.snapshotKey;
|
|
2321
|
+
}
|
|
1986
2322
|
async function buildSnapshots(context, request2, control, progress) {
|
|
1987
2323
|
const { signal } = control;
|
|
1988
2324
|
const scope = runnerSandboxScope(context, progress, {
|
|
1989
2325
|
keepMs: 0,
|
|
1990
2326
|
basePolicy: runnerNetworkPolicy(request2.build.plan.options),
|
|
2327
|
+
managedCredentials: request2.build.plan.options.managedCredentials,
|
|
1991
2328
|
signal
|
|
1992
2329
|
});
|
|
1993
2330
|
try {
|
|
@@ -2031,7 +2368,7 @@ async function publishIn(context, request2, control, progress) {
|
|
|
2031
2368
|
teamId: access.teamId,
|
|
2032
2369
|
projectId: access.projectId,
|
|
2033
2370
|
region: options.region,
|
|
2034
|
-
|
|
2371
|
+
image: options.image,
|
|
2035
2372
|
runnerName: options.name,
|
|
2036
2373
|
snapshotKey: plan.snapshotKey
|
|
2037
2374
|
});
|
|
@@ -2108,27 +2445,167 @@ function localUserName() {
|
|
|
2108
2445
|
}
|
|
2109
2446
|
|
|
2110
2447
|
// src/runner/secrets.ts
|
|
2448
|
+
var CREDENTIAL_PROBLEM_KINDS = [
|
|
2449
|
+
"missing",
|
|
2450
|
+
"multiline",
|
|
2451
|
+
"short",
|
|
2452
|
+
"gh-not-installed",
|
|
2453
|
+
"gh-not-authenticated",
|
|
2454
|
+
"gh-timed-out",
|
|
2455
|
+
"gh-failed",
|
|
2456
|
+
"gh-preframed"
|
|
2457
|
+
];
|
|
2111
2458
|
function declaredSecretValues(options, env) {
|
|
2112
2459
|
if (options === void 0) return [];
|
|
2113
2460
|
const seen = /* @__PURE__ */ new Set();
|
|
2114
2461
|
const values = [];
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2462
|
+
const add = (value) => {
|
|
2463
|
+
if (value.length === 0 || seen.has(value)) return;
|
|
2464
|
+
seen.add(value);
|
|
2465
|
+
values.push(value);
|
|
2466
|
+
};
|
|
2467
|
+
for (const { source } of options.credentials) {
|
|
2468
|
+
switch (source.kind) {
|
|
2469
|
+
case "env": {
|
|
2470
|
+
const value = readSecretSourceValue(source, env);
|
|
2471
|
+
if (value !== void 0) add(value);
|
|
2472
|
+
break;
|
|
2473
|
+
}
|
|
2474
|
+
case "gh": {
|
|
2475
|
+
if (source.env !== void 0) {
|
|
2476
|
+
const raw = ownNonEmpty(env, source.env);
|
|
2477
|
+
if (raw !== void 0) {
|
|
2478
|
+
for (const form of ghEnvRedactionForms(raw)) add(form);
|
|
2479
|
+
}
|
|
2480
|
+
}
|
|
2481
|
+
break;
|
|
2482
|
+
}
|
|
2483
|
+
}
|
|
2484
|
+
}
|
|
2485
|
+
for (const { source } of options.unsafeSecretEnvVars) {
|
|
2119
2486
|
const value = readSecretSourceValue(source, env);
|
|
2120
|
-
if (value !== void 0)
|
|
2487
|
+
if (value !== void 0) add(value);
|
|
2121
2488
|
}
|
|
2122
2489
|
return values;
|
|
2123
2490
|
}
|
|
2124
|
-
function readCredentials(options, env) {
|
|
2125
|
-
const
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2491
|
+
async function readCredentials(options, env, context) {
|
|
2492
|
+
const envCache = /* @__PURE__ */ new Map();
|
|
2493
|
+
const overrideEnvFailures = /* @__PURE__ */ new Set();
|
|
2494
|
+
const ghCache = /* @__PURE__ */ new Map();
|
|
2495
|
+
const ghFailureSeen = /* @__PURE__ */ new Set();
|
|
2496
|
+
const problems = [];
|
|
2497
|
+
const credentials2 = [];
|
|
2498
|
+
const secretSet = /* @__PURE__ */ new Set();
|
|
2499
|
+
const addSecrets = (forms) => {
|
|
2500
|
+
for (const form of forms) {
|
|
2501
|
+
if (form.length > 0) secretSet.add(form);
|
|
2502
|
+
}
|
|
2503
|
+
};
|
|
2504
|
+
for (const entry of options.credentials) {
|
|
2505
|
+
const { domain, header, source, requests } = entry;
|
|
2506
|
+
switch (source.kind) {
|
|
2507
|
+
case "env": {
|
|
2508
|
+
const id = secretSourceId(source);
|
|
2509
|
+
let read = envCache.get(id);
|
|
2510
|
+
if (read === void 0) {
|
|
2511
|
+
read = readSecretSource(source, env);
|
|
2512
|
+
envCache.set(id, read);
|
|
2513
|
+
if (!read.ok) {
|
|
2514
|
+
problems.push(envVariableProblem(describeSecretSource(source), read.problem));
|
|
2515
|
+
}
|
|
2516
|
+
}
|
|
2517
|
+
if (read.ok) {
|
|
2518
|
+
credentials2.push({ domain, header, value: read.value, requests });
|
|
2519
|
+
addSecrets([read.value]);
|
|
2520
|
+
}
|
|
2521
|
+
break;
|
|
2522
|
+
}
|
|
2523
|
+
case "gh": {
|
|
2524
|
+
const host = resolveGhHost(source);
|
|
2525
|
+
const format = resolveGhFormat(domain, source);
|
|
2526
|
+
const envOverride = source.env === void 0 ? void 0 : ownNonEmpty(env, source.env);
|
|
2527
|
+
if (envOverride !== void 0 && source.env !== void 0) {
|
|
2528
|
+
const framed2 = frameGhToken(envOverride, format);
|
|
2529
|
+
if (!framed2.ok) {
|
|
2530
|
+
const key = `env:${source.env}:${framed2.problem}`;
|
|
2531
|
+
if (!overrideEnvFailures.has(key)) {
|
|
2532
|
+
overrideEnvFailures.add(key);
|
|
2533
|
+
if (framed2.problem === "gh-preframed") {
|
|
2534
|
+
problems.push({
|
|
2535
|
+
name: source.env,
|
|
2536
|
+
problem: "gh-preframed",
|
|
2537
|
+
detail: `${source.env} must hold a raw token, not a pre-framed Authorization header`,
|
|
2538
|
+
hint: `Set ${source.env} to the raw token: storm frames it as ${format === "basic" ? "Basic" : "Bearer"} automatically.`
|
|
2539
|
+
});
|
|
2540
|
+
} else {
|
|
2541
|
+
problems.push(envVariableProblem(source.env, framed2.problem));
|
|
2542
|
+
}
|
|
2543
|
+
}
|
|
2544
|
+
} else {
|
|
2545
|
+
credentials2.push({ domain, header, value: framed2.headerValue, requests });
|
|
2546
|
+
addSecrets(framed2.secrets);
|
|
2547
|
+
}
|
|
2548
|
+
break;
|
|
2549
|
+
}
|
|
2550
|
+
let ghRead = ghCache.get(host);
|
|
2551
|
+
if (ghRead === void 0) {
|
|
2552
|
+
ghRead = await context.ghTokens.readToken({ host });
|
|
2553
|
+
ghCache.set(host, ghRead);
|
|
2554
|
+
}
|
|
2555
|
+
const label = `gh (${host})`;
|
|
2556
|
+
if (!ghRead.ok) {
|
|
2557
|
+
const failureKey = `gh:${host}:${source.env ?? ""}`;
|
|
2558
|
+
if (!ghFailureSeen.has(failureKey)) {
|
|
2559
|
+
ghFailureSeen.add(failureKey);
|
|
2560
|
+
const { failure } = ghRead;
|
|
2561
|
+
const problemKind = failure.kind === "not-installed" ? "gh-not-installed" : failure.kind === "not-authenticated" ? "gh-not-authenticated" : failure.kind === "timed-out" ? "gh-timed-out" : "gh-failed";
|
|
2562
|
+
const baseHint = failure.kind === "not-installed" ? "Install the GitHub CLI (gh) and run `gh auth login`" : failure.kind === "not-authenticated" ? `Run \`gh auth login --hostname ${host}\`` : `Check that \`gh auth token --hostname ${host}\` succeeds on this machine`;
|
|
2563
|
+
problems.push({
|
|
2564
|
+
name: label,
|
|
2565
|
+
problem: problemKind,
|
|
2566
|
+
detail: failure.message,
|
|
2567
|
+
hint: withEnvFallback(baseHint, source.env)
|
|
2568
|
+
});
|
|
2569
|
+
}
|
|
2570
|
+
break;
|
|
2571
|
+
}
|
|
2572
|
+
const framed = frameGhToken(ghRead.token, format);
|
|
2573
|
+
if (!framed.ok) {
|
|
2574
|
+
const failureKey = `gh-token:${host}:${framed.problem}`;
|
|
2575
|
+
if (!ghFailureSeen.has(failureKey)) {
|
|
2576
|
+
ghFailureSeen.add(failureKey);
|
|
2577
|
+
if (framed.problem === "gh-preframed") {
|
|
2578
|
+
problems.push({
|
|
2579
|
+
name: label,
|
|
2580
|
+
problem: "gh-preframed",
|
|
2581
|
+
detail: `gh auth token --hostname ${host} returned a pre-framed Authorization header instead of a raw token`,
|
|
2582
|
+
hint: withEnvFallback(`Re-authenticate with \`gh auth login --hostname ${host}\``, source.env)
|
|
2583
|
+
});
|
|
2584
|
+
} else if (framed.problem === "multiline") {
|
|
2585
|
+
problems.push({
|
|
2586
|
+
name: label,
|
|
2587
|
+
problem: "multiline",
|
|
2588
|
+
detail: `gh auth token --hostname ${host} returned a value with a carriage return or a line feed`,
|
|
2589
|
+
hint: withEnvFallback(`Re-authenticate with \`gh auth login --hostname ${host}\``, source.env)
|
|
2590
|
+
});
|
|
2591
|
+
} else {
|
|
2592
|
+
problems.push({
|
|
2593
|
+
name: label,
|
|
2594
|
+
problem: "short",
|
|
2595
|
+
detail: `gh auth token --hostname ${host} returned fewer than ${SECRET_MIN_LENGTH} characters`,
|
|
2596
|
+
hint: withEnvFallback(`Re-authenticate with \`gh auth login --hostname ${host}\``, source.env)
|
|
2597
|
+
});
|
|
2598
|
+
}
|
|
2599
|
+
}
|
|
2600
|
+
break;
|
|
2601
|
+
}
|
|
2602
|
+
credentials2.push({ domain, header, value: framed.headerValue, requests });
|
|
2603
|
+
addSecrets(framed.secrets);
|
|
2604
|
+
break;
|
|
2605
|
+
}
|
|
2606
|
+
}
|
|
2607
|
+
}
|
|
2608
|
+
return problems.length === 0 ? { ok: true, credentials: credentials2, secrets: [...secretSet] } : { ok: false, problems };
|
|
2132
2609
|
}
|
|
2133
2610
|
function readUnsafeSecretEnvVars(options, env) {
|
|
2134
2611
|
const read = readUniqueSources(options.unsafeSecretEnvVars, env, ({ name }, value) => [
|
|
@@ -2153,6 +2630,38 @@ function readUniqueSources(entries, env, map) {
|
|
|
2153
2630
|
}
|
|
2154
2631
|
return variables.length === 0 ? { ok: true, items } : { ok: false, variables };
|
|
2155
2632
|
}
|
|
2633
|
+
function envVariableProblem(name, problem) {
|
|
2634
|
+
switch (problem) {
|
|
2635
|
+
case "missing":
|
|
2636
|
+
return {
|
|
2637
|
+
name,
|
|
2638
|
+
problem,
|
|
2639
|
+
detail: `${name} is not set`,
|
|
2640
|
+
hint: `Set ${name} in this machine's environment.`
|
|
2641
|
+
};
|
|
2642
|
+
case "multiline":
|
|
2643
|
+
return {
|
|
2644
|
+
name,
|
|
2645
|
+
problem,
|
|
2646
|
+
detail: `${name} holds a carriage return or a line feed`,
|
|
2647
|
+
hint: `Set ${name} to a value on one line: storm hides each value in output a line at a time, and doesn't trim one.`
|
|
2648
|
+
};
|
|
2649
|
+
case "short":
|
|
2650
|
+
return {
|
|
2651
|
+
name,
|
|
2652
|
+
problem,
|
|
2653
|
+
detail: `${name} holds fewer than ${SECRET_MIN_LENGTH} characters`,
|
|
2654
|
+
hint: `Set ${name} to the whole secret.`
|
|
2655
|
+
};
|
|
2656
|
+
}
|
|
2657
|
+
}
|
|
2658
|
+
function withEnvFallback(base, envVar) {
|
|
2659
|
+
return envVar === void 0 ? `${base}.` : `${base}, or set ${envVar} in this machine's environment.`;
|
|
2660
|
+
}
|
|
2661
|
+
function ownNonEmpty(env, name) {
|
|
2662
|
+
const value = Object.hasOwn(env, name) ? env[name] : void 0;
|
|
2663
|
+
return value === void 0 || value.length === 0 ? void 0 : value;
|
|
2664
|
+
}
|
|
2156
2665
|
|
|
2157
2666
|
// src/runner/snapshot-inspect.ts
|
|
2158
2667
|
async function inspectLocalSnapshotIndex(context, request2) {
|
|
@@ -2162,7 +2671,7 @@ async function inspectLocalSnapshotIndex(context, request2) {
|
|
|
2162
2671
|
if (!listed.ok) return { kind: "local-index-unreadable", ...listed.failure };
|
|
2163
2672
|
const { directory, entries, unreadable } = listed.value;
|
|
2164
2673
|
const now = context.clock.now();
|
|
2165
|
-
const ofRunner = (entry) => options !== void 0 && entry
|
|
2674
|
+
const ofRunner = (entry) => options !== void 0 && matchesRunnerTarget(entry, options);
|
|
2166
2675
|
const shows = (entry) => request2.all || options === void 0 || ofRunner(entry);
|
|
2167
2676
|
const shown = entries.filter(shows);
|
|
2168
2677
|
const root = await checkout.repositoryRoot({ cwd: request2.cwd });
|
|
@@ -2319,7 +2828,7 @@ async function listSharedSnapshots(context, request2, signal) {
|
|
|
2319
2828
|
teamId: access.teamId,
|
|
2320
2829
|
projectId: access.projectId,
|
|
2321
2830
|
region: runner.region,
|
|
2322
|
-
|
|
2831
|
+
image: runner.image,
|
|
2323
2832
|
runnerName: runner.name,
|
|
2324
2833
|
snapshotKey: snapshotKey2
|
|
2325
2834
|
});
|
|
@@ -2603,9 +3112,9 @@ function partitionUntracked(entries) {
|
|
|
2603
3112
|
return { files, nestedRepositories };
|
|
2604
3113
|
}
|
|
2605
3114
|
function displayCommand(command, args) {
|
|
2606
|
-
return [command, ...args].map(
|
|
3115
|
+
return [command, ...args].map(shellQuote2).join(" ");
|
|
2607
3116
|
}
|
|
2608
|
-
function
|
|
3117
|
+
function shellQuote2(argument) {
|
|
2609
3118
|
return /^[\w@%+=:,./^{}-]+$/.test(argument) ? argument : `'${argument.replaceAll("'", `'\\''`)}'`;
|
|
2610
3119
|
}
|
|
2611
3120
|
|
|
@@ -2630,7 +3139,8 @@ function liveCheckoutGateway() {
|
|
|
2630
3139
|
readFileAt: ({ repoRoot, commit, path }) => readFileAt(repoRoot, commit, path),
|
|
2631
3140
|
submodules: ({ repoRoot }) => submodules(repoRoot),
|
|
2632
3141
|
assembleUpload: ({ repoRoot, base }) => assembleUpload(repoRoot, base),
|
|
2633
|
-
baseArchive: ({ repoRoot, base }) => baseArchive(repoRoot, base)
|
|
3142
|
+
baseArchive: ({ repoRoot, base }) => baseArchive(repoRoot, base),
|
|
3143
|
+
remoteUrl: ({ repoRoot, remote }) => remoteUrl(repoRoot, remote)
|
|
2634
3144
|
};
|
|
2635
3145
|
}
|
|
2636
3146
|
async function repositoryRoot(cwd) {
|
|
@@ -2731,6 +3241,10 @@ async function baseArchive(repoRoot, base) {
|
|
|
2731
3241
|
value: { tarball: tarball.stdout, fileList: fileList.stdout, files: splitNul(fileList.stdout).length }
|
|
2732
3242
|
};
|
|
2733
3243
|
}
|
|
3244
|
+
async function remoteUrl(repoRoot, remote) {
|
|
3245
|
+
const run = await git(repoRoot, ["remote", "get-url", "--", remote]);
|
|
3246
|
+
return run.ok ? { ok: true, value: run.stdout.toString("utf8").replace(/\r?\n$/, "") } : run;
|
|
3247
|
+
}
|
|
2734
3248
|
function git(repoRoot, args) {
|
|
2735
3249
|
const argv = ["-C", repoRoot, ...args];
|
|
2736
3250
|
return new Promise((resolve) => {
|
|
@@ -2794,6 +3308,86 @@ function createTarball(repoRoot, paths) {
|
|
|
2794
3308
|
});
|
|
2795
3309
|
}
|
|
2796
3310
|
|
|
3311
|
+
// src/runner/live/gh-token-gateway.ts
|
|
3312
|
+
import { execFile as execFile2 } from "node:child_process";
|
|
3313
|
+
|
|
3314
|
+
// src/runner/live/gh-output.ts
|
|
3315
|
+
function stripSingleTrailingLineBreak(stdout) {
|
|
3316
|
+
if (stdout.endsWith("\r\n")) return stdout.slice(0, -2);
|
|
3317
|
+
if (stdout.endsWith("\n")) return stdout.slice(0, -1);
|
|
3318
|
+
return stdout;
|
|
3319
|
+
}
|
|
3320
|
+
function classifyGhTokenError(info) {
|
|
3321
|
+
const { host, code, killed, stderr, timeoutMs } = info;
|
|
3322
|
+
if (code === "ENOENT") {
|
|
3323
|
+
return { kind: "not-installed", host, message: "gh CLI is not installed or not on PATH" };
|
|
3324
|
+
}
|
|
3325
|
+
if (killed || code === "ETIMEDOUT") {
|
|
3326
|
+
return { kind: "timed-out", host, message: `gh auth token --hostname ${host} timed out after ${timeoutMs}ms` };
|
|
3327
|
+
}
|
|
3328
|
+
if (NOT_AUTHENTICATED_PATTERN.test(stderr)) {
|
|
3329
|
+
return { kind: "not-authenticated", host, message: `gh is not authenticated for ${host}` };
|
|
3330
|
+
}
|
|
3331
|
+
return {
|
|
3332
|
+
kind: "failed",
|
|
3333
|
+
host,
|
|
3334
|
+
message: typeof code === "number" ? `gh auth token --hostname ${host} exited ${code}` : `gh auth token --hostname ${host} failed`
|
|
3335
|
+
};
|
|
3336
|
+
}
|
|
3337
|
+
var NOT_AUTHENTICATED_PATTERN = /not logged in|no oauth token|no token|gh auth login|authentication failed|to get started with github cli/i;
|
|
3338
|
+
|
|
3339
|
+
// src/runner/live/gh-token-gateway.ts
|
|
3340
|
+
var GH_TOKEN_TIMEOUT_MS = 1e4;
|
|
3341
|
+
var GH_MAX_BUFFER = 64 * 1024;
|
|
3342
|
+
function liveGhTokenGateway(options = {}) {
|
|
3343
|
+
const command = options.command ?? "gh";
|
|
3344
|
+
const timeoutMs = options.timeoutMs ?? GH_TOKEN_TIMEOUT_MS;
|
|
3345
|
+
const env = options.env;
|
|
3346
|
+
return {
|
|
3347
|
+
readToken: ({ host }) => new Promise((resolve) => {
|
|
3348
|
+
execFile2(
|
|
3349
|
+
command,
|
|
3350
|
+
["auth", "token", "--hostname", host],
|
|
3351
|
+
{
|
|
3352
|
+
encoding: "utf8",
|
|
3353
|
+
timeout: timeoutMs,
|
|
3354
|
+
maxBuffer: GH_MAX_BUFFER,
|
|
3355
|
+
...env === void 0 ? {} : { env: { ...env } }
|
|
3356
|
+
},
|
|
3357
|
+
(error, stdout, stderr) => {
|
|
3358
|
+
if (error === null) {
|
|
3359
|
+
const token = stripSingleTrailingLineBreak(stdout);
|
|
3360
|
+
if (token.length === 0) {
|
|
3361
|
+
resolve({
|
|
3362
|
+
ok: false,
|
|
3363
|
+
failure: {
|
|
3364
|
+
kind: "not-authenticated",
|
|
3365
|
+
host,
|
|
3366
|
+
message: `gh is not authenticated for ${host}`
|
|
3367
|
+
}
|
|
3368
|
+
});
|
|
3369
|
+
return;
|
|
3370
|
+
}
|
|
3371
|
+
resolve({ ok: true, token });
|
|
3372
|
+
return;
|
|
3373
|
+
}
|
|
3374
|
+
const err = error;
|
|
3375
|
+
resolve({
|
|
3376
|
+
ok: false,
|
|
3377
|
+
failure: classifyGhTokenError({
|
|
3378
|
+
host,
|
|
3379
|
+
code: err.code,
|
|
3380
|
+
killed: err.killed === true,
|
|
3381
|
+
stderr: typeof stderr === "string" ? stderr : "",
|
|
3382
|
+
timeoutMs
|
|
3383
|
+
})
|
|
3384
|
+
});
|
|
3385
|
+
}
|
|
3386
|
+
);
|
|
3387
|
+
})
|
|
3388
|
+
};
|
|
3389
|
+
}
|
|
3390
|
+
|
|
2797
3391
|
// src/runner/live/sandbox-errors.ts
|
|
2798
3392
|
function apiStatus(error) {
|
|
2799
3393
|
if (typeof error !== "object" || error === null) return void 0;
|
|
@@ -2847,8 +3441,7 @@ function liveRunnerSandboxGateway() {
|
|
|
2847
3441
|
const { Sandbox } = await sdk();
|
|
2848
3442
|
const sandbox = await Sandbox.create({
|
|
2849
3443
|
...credentials(access),
|
|
2850
|
-
|
|
2851
|
-
runtime: request2.runtime,
|
|
3444
|
+
image: request2.image,
|
|
2852
3445
|
...request2.name === void 0 ? {} : { name: request2.name },
|
|
2853
3446
|
...placement(request2),
|
|
2854
3447
|
...signal === void 0 ? {} : { signal }
|
|
@@ -3250,9 +3843,17 @@ function placement(request2) {
|
|
|
3250
3843
|
timeout: request2.timeoutMs,
|
|
3251
3844
|
persistent: false,
|
|
3252
3845
|
tags: { ...request2.tags },
|
|
3253
|
-
networkPolicy: sdkNetworkPolicy(request2.networkPolicy)
|
|
3846
|
+
networkPolicy: sdkNetworkPolicy(request2.networkPolicy),
|
|
3847
|
+
...request2.managedCredentials !== void 0 && request2.managedCredentials.length > 0 ? { credentials: sdkManagedCredentials(request2.managedCredentials) } : {}
|
|
3254
3848
|
};
|
|
3255
3849
|
}
|
|
3850
|
+
function sdkManagedCredentials(providers) {
|
|
3851
|
+
const result = {};
|
|
3852
|
+
for (const provider of providers) {
|
|
3853
|
+
if (provider === "npm") result.npm = true;
|
|
3854
|
+
}
|
|
3855
|
+
return result;
|
|
3856
|
+
}
|
|
3256
3857
|
function sdkNetworkPolicy(policy) {
|
|
3257
3858
|
switch (policy.kind) {
|
|
3258
3859
|
case "allow-all":
|
|
@@ -3441,11 +4042,11 @@ import { z as z3 } from "zod";
|
|
|
3441
4042
|
var isoTime = z3.string().refine((value) => !Number.isNaN(Date.parse(value)), { message: "not a time" });
|
|
3442
4043
|
var nonEmpty = z3.string().min(1);
|
|
3443
4044
|
var entrySchema = z3.object({
|
|
3444
|
-
version: z3.literal(
|
|
4045
|
+
version: z3.literal(2),
|
|
3445
4046
|
teamId: nonEmpty,
|
|
3446
4047
|
projectId: nonEmpty,
|
|
3447
4048
|
region: nonEmpty,
|
|
3448
|
-
|
|
4049
|
+
image: nonEmpty,
|
|
3449
4050
|
runnerName: nonEmpty,
|
|
3450
4051
|
snapshotKey: nonEmpty,
|
|
3451
4052
|
base: nonEmpty,
|
|
@@ -3461,7 +4062,7 @@ function parseSnapshotEntry(text) {
|
|
|
3461
4062
|
return { ok: false, reason: "not JSON" };
|
|
3462
4063
|
}
|
|
3463
4064
|
const version = typeof json === "object" && json !== null ? json.version : void 0;
|
|
3464
|
-
if (version !==
|
|
4065
|
+
if (version !== 2) return { ok: false, reason: `unknown version ${JSON.stringify(version) ?? "(none)"}` };
|
|
3465
4066
|
const parsed = entrySchema.safeParse(json);
|
|
3466
4067
|
if (!parsed.success) {
|
|
3467
4068
|
const issue = parsed.error.issues[0];
|
|
@@ -3472,14 +4073,14 @@ function parseSnapshotEntry(text) {
|
|
|
3472
4073
|
return { ok: true, value: entry };
|
|
3473
4074
|
}
|
|
3474
4075
|
function snapshotEntryText(entry) {
|
|
3475
|
-
const { teamId, projectId, region,
|
|
4076
|
+
const { teamId, projectId, region, image, runnerName, snapshotKey: snapshotKey2, base } = entry;
|
|
3476
4077
|
const { snapshotId, createdAt, expiresAt } = entry;
|
|
3477
4078
|
const record = {
|
|
3478
|
-
version:
|
|
4079
|
+
version: 2,
|
|
3479
4080
|
teamId,
|
|
3480
4081
|
projectId,
|
|
3481
4082
|
region,
|
|
3482
|
-
|
|
4083
|
+
image,
|
|
3483
4084
|
runnerName,
|
|
3484
4085
|
snapshotKey: snapshotKey2,
|
|
3485
4086
|
base,
|
|
@@ -3642,7 +4243,7 @@ async function lookupSharedSnapshot(context, request2, signal) {
|
|
|
3642
4243
|
teamId: access.teamId,
|
|
3643
4244
|
projectId: access.projectId,
|
|
3644
4245
|
region: runner.region,
|
|
3645
|
-
|
|
4246
|
+
image: runner.image,
|
|
3646
4247
|
runnerName: runner.name,
|
|
3647
4248
|
snapshotKey: snapshotKey2
|
|
3648
4249
|
});
|
|
@@ -3924,7 +4525,7 @@ async function readyFromSnapshot(context, request2, control, progress) {
|
|
|
3924
4525
|
buildMs: builtOutputs.value,
|
|
3925
4526
|
vcpus: prepared.vcpus,
|
|
3926
4527
|
region: options.region,
|
|
3927
|
-
|
|
4528
|
+
image: options.image,
|
|
3928
4529
|
repoRoot,
|
|
3929
4530
|
cwd: posix.join(SANDBOX_ROOT, options.cwd),
|
|
3930
4531
|
env: options.env,
|
|
@@ -3980,6 +4581,7 @@ async function chooseSnapshotForRun(context, request2, control, progress) {
|
|
|
3980
4581
|
const scope = runnerSandboxScope(context, progress, {
|
|
3981
4582
|
keepMs: 0,
|
|
3982
4583
|
basePolicy: runnerNetworkPolicy(request2.prepared.options),
|
|
4584
|
+
managedCredentials: request2.prepared.options.managedCredentials,
|
|
3983
4585
|
signal
|
|
3984
4586
|
});
|
|
3985
4587
|
try {
|
|
@@ -4122,10 +4724,13 @@ function openRunnerSession(context, request2, control, progress) {
|
|
|
4122
4724
|
const hasUnsafeSecretEnvVars = Object.keys(unsafeSecretEnvVars).length > 0;
|
|
4123
4725
|
if (hasUnsafeSecretEnvVars && request2.keepMs > 0)
|
|
4124
4726
|
throw new Error("a runner session with unsafeSecretEnvVars can't keep its runner sandbox");
|
|
4727
|
+
if (request2.prepared.options.managedCredentials.length > 0 && request2.keepMs > 0)
|
|
4728
|
+
throw new Error("a runner session with managedCredentials can't keep its runner sandbox");
|
|
4125
4729
|
let commandRunning = false;
|
|
4126
4730
|
const scope = runnerSandboxScope(context, progress, {
|
|
4127
4731
|
keepMs: request2.keepMs,
|
|
4128
4732
|
basePolicy: runnerNetworkPolicy(request2.prepared.options),
|
|
4733
|
+
managedCredentials: request2.prepared.options.managedCredentials,
|
|
4129
4734
|
signal,
|
|
4130
4735
|
commandRunning: () => commandRunning
|
|
4131
4736
|
});
|
|
@@ -5059,7 +5664,7 @@ function errorMessage(error) {
|
|
|
5059
5664
|
}
|
|
5060
5665
|
|
|
5061
5666
|
// src/credential/live/vercel-cli-gateway.ts
|
|
5062
|
-
import { execFile as
|
|
5667
|
+
import { execFile as execFile3 } from "node:child_process";
|
|
5063
5668
|
import { tmpdir } from "node:os";
|
|
5064
5669
|
|
|
5065
5670
|
// src/credential/live/vercel-process.ts
|
|
@@ -5155,7 +5760,7 @@ function liveCredentialGateway() {
|
|
|
5155
5760
|
function runVercel(args) {
|
|
5156
5761
|
return new Promise((resolve) => {
|
|
5157
5762
|
try {
|
|
5158
|
-
|
|
5763
|
+
execFile3(
|
|
5159
5764
|
"vercel",
|
|
5160
5765
|
args,
|
|
5161
5766
|
{
|
|
@@ -5579,8 +6184,10 @@ export {
|
|
|
5579
6184
|
resolveSandboxCountDefault,
|
|
5580
6185
|
lineSplitter,
|
|
5581
6186
|
prepareSnapshotBuild,
|
|
6187
|
+
sameSnapshotBuild,
|
|
5582
6188
|
buildSnapshots,
|
|
5583
6189
|
liveCheckoutGateway,
|
|
6190
|
+
liveGhTokenGateway,
|
|
5584
6191
|
liveRunnerSandboxGateway,
|
|
5585
6192
|
liveRunnerTerminal,
|
|
5586
6193
|
localUserName,
|
|
@@ -5589,6 +6196,7 @@ export {
|
|
|
5589
6196
|
prepareRunner,
|
|
5590
6197
|
chooseSnapshotForRun,
|
|
5591
6198
|
SANDBOX_TEST_EVENTS_PATH,
|
|
6199
|
+
CREDENTIAL_PROBLEM_KINDS,
|
|
5592
6200
|
declaredSecretValues,
|
|
5593
6201
|
readCredentials,
|
|
5594
6202
|
readUnsafeSecretEnvVars,
|