overvues 0.0.0-stage → 0.4.10
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/README.md +60 -2
- package/dist/ansi.js +24 -0
- package/dist/attach-client.js +586 -0
- package/dist/auth-connect-browser.js +112 -0
- package/dist/auth-connect.js +306 -0
- package/dist/browser-bootstrap.js +190 -0
- package/dist/browser-loopback.js +289 -0
- package/dist/build-identity.js +6 -0
- package/dist/codex-reviewer-apparmor.json +4 -0
- package/dist/codex-reviewer-seccomp.json +1238 -0
- package/dist/codex-runtime-protocol.js +1 -0
- package/dist/codex-subscription.js +53 -0
- package/dist/config.js +297 -0
- package/dist/connect-comparison-code.js +26 -0
- package/dist/development-runner.js +109 -0
- package/dist/dns-doctor.js +390 -0
- package/dist/docker-names.js +47 -0
- package/dist/doctor.js +114 -0
- package/dist/gadget-job.js +804 -0
- package/dist/health-check.js +112 -0
- package/dist/help.js +71 -0
- package/dist/host-auth.js +22 -0
- package/dist/host-diagnostics.js +20 -0
- package/dist/host-runtime-identity.js +39 -0
- package/dist/host-runtime-metadata.js +56 -0
- package/dist/host-service.js +377 -0
- package/dist/host-stack.js +484 -0
- package/dist/host-supervisor.js +237 -0
- package/dist/host-update.js +387 -0
- package/dist/hub-address.js +100 -0
- package/dist/hub-client.js +459 -0
- package/dist/hub-kind.js +88 -0
- package/dist/identity.js +73 -0
- package/dist/index.js +185 -0
- package/dist/init.js +295 -0
- package/dist/isolated-run-cache.js +116 -0
- package/dist/local-stack.js +685 -0
- package/dist/machine-capacity.js +128 -0
- package/dist/managed-runner-image.js +13 -0
- package/dist/os-acted-record.js +49 -0
- package/dist/os-adapter.js +8190 -0
- package/dist/os-command.js +292 -0
- package/dist/os-handoff.js +274 -0
- package/dist/os-keychain.js +247 -0
- package/dist/os-machine.js +818 -0
- package/dist/os-owner.js +61 -0
- package/dist/os-private-file.js +98 -0
- package/dist/os-protocol.js +468 -0
- package/dist/os-session-store.js +133 -0
- package/dist/os-status.js +102 -0
- package/dist/picker.js +863 -0
- package/dist/portable-workspace-capability.js +60 -0
- package/dist/project-environment-capability.js +62 -0
- package/dist/project-environment.js +28 -0
- package/dist/project-preparation.js +134 -0
- package/dist/readiness.js +28 -0
- package/dist/redaction.js +27 -0
- package/dist/reviewer-isolation-capability.js +61 -0
- package/dist/runner-api-auth.js +80 -0
- package/dist/runner-command-fence.js +536 -0
- package/dist/runner-inspection.js +57 -0
- package/dist/runner-inventory.js +587 -0
- package/dist/runner-server.js +2520 -0
- package/dist/runner-session.js +470 -0
- package/dist/runner-slug-folder.js +39 -0
- package/dist/runner-slug.js +40 -0
- package/dist/setup.js +139 -0
- package/dist/shutdown.js +102 -0
- package/dist/splash.js +65 -0
- package/dist/staged-workspaces.js +441 -0
- package/dist/staging-disk.js +97 -0
- package/dist/terminal-lane.js +339 -0
- package/dist/terminal-recovery.js +502 -0
- package/licenses/capnweb.txt +23 -0
- package/licenses/moby-profiles.txt +212 -0
- package/licenses/ws.txt +22 -0
- package/package.json +30 -4
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
import { connectComparisonCode } from "./connect-comparison-code.js";
|
|
2
|
+
import { spawn } from "node:child_process";
|
|
3
|
+
import { randomUUID, webcrypto } from "node:crypto";
|
|
4
|
+
import { createServer } from "node:http";
|
|
5
|
+
import { stdin as input, stdout as output } from "node:process";
|
|
6
|
+
import { createInterface } from "node:readline/promises";
|
|
7
|
+
import { exportJWK } from "jose";
|
|
8
|
+
const LISTENER_FORCE_CLOSE_MS = 250;
|
|
9
|
+
export function exactBrowserHubOrigin(value) {
|
|
10
|
+
const parsed = new URL(value.trim());
|
|
11
|
+
if ((parsed.protocol !== "https:" && parsed.protocol !== "http:")
|
|
12
|
+
|| parsed.username
|
|
13
|
+
|| parsed.password
|
|
14
|
+
|| (parsed.pathname !== "/" && parsed.pathname !== "")
|
|
15
|
+
|| parsed.search
|
|
16
|
+
|| parsed.hash) {
|
|
17
|
+
throw new Error("Hub URL must be an exact HTTP or HTTPS origin.");
|
|
18
|
+
}
|
|
19
|
+
return parsed.origin;
|
|
20
|
+
}
|
|
21
|
+
export function normalizeBrowserConnectionCode(value) {
|
|
22
|
+
return value.trim().replace(/\s+/g, "");
|
|
23
|
+
}
|
|
24
|
+
function readHeader(value) {
|
|
25
|
+
return Array.isArray(value) ? value[0] : value;
|
|
26
|
+
}
|
|
27
|
+
function corsHeaders(origin) {
|
|
28
|
+
return {
|
|
29
|
+
"Access-Control-Allow-Origin": origin,
|
|
30
|
+
"Access-Control-Allow-Methods": "POST, OPTIONS",
|
|
31
|
+
"Access-Control-Allow-Headers": "Content-Type",
|
|
32
|
+
"Access-Control-Max-Age": "300",
|
|
33
|
+
Vary: "Origin",
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
function writeJson(res, status, body, allowedOrigin) {
|
|
37
|
+
res.writeHead(status, {
|
|
38
|
+
"Content-Type": "application/json; charset=utf-8",
|
|
39
|
+
"Cache-Control": "no-store",
|
|
40
|
+
...(allowedOrigin ? corsHeaders(allowedOrigin) : {}),
|
|
41
|
+
});
|
|
42
|
+
res.end(`${JSON.stringify(body)}\n`);
|
|
43
|
+
}
|
|
44
|
+
async function readJsonBody(req, maxBodyBytes, messages) {
|
|
45
|
+
const chunks = [];
|
|
46
|
+
let total = 0;
|
|
47
|
+
for await (const chunk of req) {
|
|
48
|
+
const next = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
|
|
49
|
+
total += next.length;
|
|
50
|
+
if (total > maxBodyBytes)
|
|
51
|
+
throw new Error(messages.bodyTooLarge);
|
|
52
|
+
chunks.push(next);
|
|
53
|
+
}
|
|
54
|
+
const raw = Buffer.concat(chunks).toString("utf8").trim();
|
|
55
|
+
if (!raw)
|
|
56
|
+
throw new Error(messages.bodyEmpty);
|
|
57
|
+
try {
|
|
58
|
+
return JSON.parse(raw);
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
throw new Error(messages.bodyInvalid);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
async function closeServer(server) {
|
|
65
|
+
if (!server.listening) {
|
|
66
|
+
server.closeAllConnections();
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
await new Promise((resolve, reject) => {
|
|
70
|
+
const forceClose = setTimeout(() => server.closeAllConnections(), LISTENER_FORCE_CLOSE_MS);
|
|
71
|
+
server.close((error) => {
|
|
72
|
+
clearTimeout(forceClose);
|
|
73
|
+
if (error)
|
|
74
|
+
reject(error);
|
|
75
|
+
else
|
|
76
|
+
resolve();
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
export function browserLaunchCommand(platform, url) {
|
|
81
|
+
return platform === "darwin"
|
|
82
|
+
? { cmd: "open", args: [url] }
|
|
83
|
+
: platform === "win32"
|
|
84
|
+
? { cmd: "rundll32.exe", args: ["url.dll,FileProtocolHandler", url] }
|
|
85
|
+
: { cmd: "xdg-open", args: [url] };
|
|
86
|
+
}
|
|
87
|
+
export function openBrowser(url) {
|
|
88
|
+
const command = browserLaunchCommand(process.platform, url);
|
|
89
|
+
return new Promise((resolve) => {
|
|
90
|
+
const child = spawn(command.cmd, command.args, { stdio: "ignore", windowsHide: true });
|
|
91
|
+
child.once("error", () => resolve(false));
|
|
92
|
+
child.once("spawn", () => child.unref());
|
|
93
|
+
child.once("close", (code) => resolve(code === 0));
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
function startManualPrompt(options, context, complete, writeStderr, interactive) {
|
|
97
|
+
if (!interactive)
|
|
98
|
+
return null;
|
|
99
|
+
const rl = createInterface({ input, output });
|
|
100
|
+
const controller = new AbortController();
|
|
101
|
+
let stopped = false;
|
|
102
|
+
writeStderr(options.messages.manualPrompt);
|
|
103
|
+
const done = (async () => {
|
|
104
|
+
while (!stopped) {
|
|
105
|
+
let code = "";
|
|
106
|
+
try {
|
|
107
|
+
code = await rl.question("Connection code: ", { signal: controller.signal });
|
|
108
|
+
}
|
|
109
|
+
catch (error) {
|
|
110
|
+
if (stopped || (error instanceof Error && error.name === "AbortError"))
|
|
111
|
+
return;
|
|
112
|
+
throw error;
|
|
113
|
+
}
|
|
114
|
+
if (stopped || !code.trim())
|
|
115
|
+
continue;
|
|
116
|
+
try {
|
|
117
|
+
await complete(await options.decodeManualCode(code, context));
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
catch (error) {
|
|
121
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
122
|
+
writeStderr(options.messages.manualRetry(message));
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
})().finally(() => rl.close());
|
|
126
|
+
return {
|
|
127
|
+
done,
|
|
128
|
+
stop: () => {
|
|
129
|
+
if (stopped)
|
|
130
|
+
return;
|
|
131
|
+
stopped = true;
|
|
132
|
+
controller.abort();
|
|
133
|
+
rl.close();
|
|
134
|
+
},
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
export async function runBrowserLoopback(options, dependencies = {}) {
|
|
138
|
+
const hubUrl = exactBrowserHubOrigin(options.hubUrl);
|
|
139
|
+
const expectedOrigin = new URL(hubUrl).origin;
|
|
140
|
+
const state = randomUUID();
|
|
141
|
+
const keyPair = await webcrypto.subtle.generateKey({ name: "ECDH", namedCurve: "P-256" }, false, ["deriveKey", "deriveBits"]);
|
|
142
|
+
let privateKey = keyPair.privateKey;
|
|
143
|
+
const publicKeyJwk = await exportJWK(keyPair.publicKey);
|
|
144
|
+
const encodedPublicKey = Buffer.from(JSON.stringify(publicKeyJwk), "utf8").toString("base64url");
|
|
145
|
+
const comparisonCode = await connectComparisonCode(publicKeyJwk);
|
|
146
|
+
const writeStderr = dependencies.writeStderr ?? ((message) => process.stderr.write(message));
|
|
147
|
+
const launchBrowser = dependencies.openBrowser ?? openBrowser;
|
|
148
|
+
const interactive = dependencies.interactive ?? Boolean(input.isTTY && output.isTTY);
|
|
149
|
+
const signalSource = dependencies.signalSource ?? process;
|
|
150
|
+
let settled = false;
|
|
151
|
+
let resolveResult;
|
|
152
|
+
let rejectResult;
|
|
153
|
+
const resultPromise = new Promise((resolve, reject) => {
|
|
154
|
+
resolveResult = resolve;
|
|
155
|
+
rejectResult = reject;
|
|
156
|
+
});
|
|
157
|
+
const server = createServer((req, res) => {
|
|
158
|
+
void (async () => {
|
|
159
|
+
const requestUrl = new URL(req.url || "/", "http://127.0.0.1");
|
|
160
|
+
const origin = readHeader(req.headers.origin);
|
|
161
|
+
const validOrigin = origin === expectedOrigin;
|
|
162
|
+
if (requestUrl.pathname !== options.callbackPath || requestUrl.search || requestUrl.hash) {
|
|
163
|
+
writeJson(res, 404, { error: "Not found." });
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
if (req.method === "OPTIONS") {
|
|
167
|
+
const requestedMethod = readHeader(req.headers["access-control-request-method"]);
|
|
168
|
+
if (!validOrigin || requestedMethod !== "POST") {
|
|
169
|
+
writeJson(res, 403, { error: "Origin not allowed." });
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
res.writeHead(204, corsHeaders(expectedOrigin));
|
|
173
|
+
res.end();
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
if (req.method !== "POST") {
|
|
177
|
+
writeJson(res, 405, { error: "Method not allowed." });
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
if (!validOrigin) {
|
|
181
|
+
writeJson(res, 403, { error: "Origin not allowed." });
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
if (!/^application\/json(?:\s*;|$)/i.test(req.headers["content-type"] ?? "")) {
|
|
185
|
+
writeJson(res, 415, { error: "Content-Type must be application/json." }, expectedOrigin);
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
if (settled) {
|
|
189
|
+
writeJson(res, 409, { error: options.messages.alreadyConsumed }, expectedOrigin);
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
try {
|
|
193
|
+
const value = await readJsonBody(req, options.maxBodyBytes, options.messages);
|
|
194
|
+
if (!privateKey)
|
|
195
|
+
throw new Error("The connection key is no longer available.");
|
|
196
|
+
const result = await options.decodeCallbackBody(value, { hubUrl, state, privateKey });
|
|
197
|
+
const responseFinished = new Promise((resolve) => res.once("finish", resolve));
|
|
198
|
+
writeJson(res, 200, { ok: true }, expectedOrigin);
|
|
199
|
+
await responseFinished;
|
|
200
|
+
await complete(result);
|
|
201
|
+
}
|
|
202
|
+
catch (error) {
|
|
203
|
+
writeJson(res, 400, {
|
|
204
|
+
error: error instanceof Error ? error.message : options.messages.callbackFailed,
|
|
205
|
+
}, expectedOrigin);
|
|
206
|
+
}
|
|
207
|
+
})().catch(() => {
|
|
208
|
+
if (!res.headersSent)
|
|
209
|
+
writeJson(res, 500, { error: options.messages.callbackFailed });
|
|
210
|
+
else
|
|
211
|
+
res.destroy();
|
|
212
|
+
});
|
|
213
|
+
});
|
|
214
|
+
const complete = async (result) => {
|
|
215
|
+
if (settled)
|
|
216
|
+
return;
|
|
217
|
+
settled = true;
|
|
218
|
+
await closeServer(server).catch(() => undefined);
|
|
219
|
+
resolveResult(result);
|
|
220
|
+
};
|
|
221
|
+
let manualPrompt = null;
|
|
222
|
+
let timeout;
|
|
223
|
+
const cancel = () => {
|
|
224
|
+
if (settled)
|
|
225
|
+
return;
|
|
226
|
+
settled = true;
|
|
227
|
+
manualPrompt?.stop();
|
|
228
|
+
rejectResult(new Error(options.messages.cancelled));
|
|
229
|
+
void closeServer(server).catch(() => undefined);
|
|
230
|
+
};
|
|
231
|
+
try {
|
|
232
|
+
await new Promise((resolve, reject) => {
|
|
233
|
+
const onError = (error) => reject(error);
|
|
234
|
+
server.once("error", onError);
|
|
235
|
+
server.listen(0, "127.0.0.1", () => {
|
|
236
|
+
server.off("error", onError);
|
|
237
|
+
resolve();
|
|
238
|
+
});
|
|
239
|
+
});
|
|
240
|
+
const address = server.address();
|
|
241
|
+
if (!address?.port)
|
|
242
|
+
throw new Error(options.messages.listenFailed);
|
|
243
|
+
signalSource.once("SIGINT", cancel);
|
|
244
|
+
signalSource.once("SIGTERM", cancel);
|
|
245
|
+
const browserUrl = options.buildBrowserUrl({
|
|
246
|
+
hubUrl,
|
|
247
|
+
port: address.port,
|
|
248
|
+
state,
|
|
249
|
+
encodedPublicKey,
|
|
250
|
+
comparisonCode,
|
|
251
|
+
});
|
|
252
|
+
writeStderr(options.messages.opening(hubUrl));
|
|
253
|
+
if (options.messages.comparisonCode)
|
|
254
|
+
writeStderr(options.messages.comparisonCode(comparisonCode));
|
|
255
|
+
if (!privateKey)
|
|
256
|
+
throw new Error("The connection key is no longer available.");
|
|
257
|
+
const context = { hubUrl, state, privateKey };
|
|
258
|
+
manualPrompt = startManualPrompt(options, context, complete, writeStderr, interactive);
|
|
259
|
+
timeout = setTimeout(() => {
|
|
260
|
+
if (settled)
|
|
261
|
+
return;
|
|
262
|
+
settled = true;
|
|
263
|
+
rejectResult(new Error(options.messages.timeout));
|
|
264
|
+
void closeServer(server).catch(() => undefined);
|
|
265
|
+
}, options.callbackTimeoutMs);
|
|
266
|
+
void launchBrowser(browserUrl).then((opened) => {
|
|
267
|
+
if (opened || settled)
|
|
268
|
+
return;
|
|
269
|
+
writeStderr(options.messages.browserFallback);
|
|
270
|
+
writeStderr(`${browserUrl}\n`);
|
|
271
|
+
}, () => {
|
|
272
|
+
if (settled)
|
|
273
|
+
return;
|
|
274
|
+
writeStderr(options.messages.browserFallback);
|
|
275
|
+
writeStderr(`${browserUrl}\n`);
|
|
276
|
+
});
|
|
277
|
+
return await resultPromise;
|
|
278
|
+
}
|
|
279
|
+
finally {
|
|
280
|
+
signalSource.off("SIGINT", cancel);
|
|
281
|
+
signalSource.off("SIGTERM", cancel);
|
|
282
|
+
if (timeout)
|
|
283
|
+
clearTimeout(timeout);
|
|
284
|
+
manualPrompt?.stop();
|
|
285
|
+
await manualPrompt?.done.catch(() => undefined);
|
|
286
|
+
await closeServer(server).catch(() => undefined);
|
|
287
|
+
privateKey = null;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// Which program this build is: `tiller` (the package `@paperwing-dev/tiller`) or `overvues` (the
|
|
2
|
+
// package `overvues`). It is fixed when the package is built, never chosen at run time: the
|
|
3
|
+
// `overvues` package's build (`packages/overvues/scripts/build.mjs`) copies this package's compiled
|
|
4
|
+
// `dist` and replaces this one module's output with `"overvues"`. Keep this file to the one line
|
|
5
|
+
// below; the build checks it byte for byte before replacing it.
|
|
6
|
+
export const BUILD_IDENTITY = "overvues";
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "tiller-codex-reviewer-v1",
|
|
3
|
+
"profile": "# SPDX-FileCopyrightText: Copyright The Moby Authors\n# SPDX-License-Identifier: Apache-2.0\n# Moby docker-default with namespace mounts permitted for Codex reviewers.\nabi <abi/3.0>,\n#include <tunables/global>\n\nprofile tiller-codex-reviewer-v1 flags=(attach_disconnected,mediate_deleted) {\n #include <abstractions/base>\n network,\n # Disallow obsolete socket families removed from the Linux kernel.\n # AF_DECnet has no AppArmor family name, so it cannot be denied here.\n deny network ax25,\n deny network ipx,\n deny network appletalk,\n deny network netrom,\n deny network rose,\n deny network econet,\n deny network atmsvc,\n deny network irda,\n deny network wanpipe,\n deny network isdn,\n deny network caif,\n # Disallow AF_ALG (Linux kernel crypto API); see https://copy.fail/\n deny network alg,\n # Disallow AF_VSOCK to prevent host/guest communication.\n deny network vsock,\n capability,\n file,\n umount,\n # Host (privileged) processes may send signals to container processes.\n signal (receive) peer=unconfined,\n # runc may send signals to container processes (for \"docker stop\").\n signal (receive) peer=runc,\n # crun may send signals to container processes (for \"docker stop\" when used with crun OCI runtime).\n signal (receive) peer=crun,\n # dockerd may send signals to container processes (for \"docker kill\").\n signal (receive) peer=unconfined,\n # Container processes may send signals amongst themselves.\n signal (send,receive) peer=tiller-codex-reviewer-v1,\n\n deny @{PROC}/* w, # deny write for all files directly in /proc (not in a subdir)\n # deny write to files not in /proc/<number>/** or /proc/sys/**\n deny @{PROC}/{[^1-9/],[^1-9/][^0-9/],[^1-9s/][^0-9y/][^0-9s/],[^1-9/][^0-9/][^0-9/][^0-9/]*}/** w,\n deny @{PROC}/sys/[^k]** w, # deny /proc/sys except /proc/sys/k* (effectively /proc/sys/kernel)\n deny @{PROC}/sys/kernel/{?,??,[^s][^h][^m]**} w, # deny everything except shm* in /proc/sys/kernel/\n deny @{PROC}/sysrq-trigger rwklx,\n deny @{PROC}/kcore rwklx,\n\n # Explicit permission also avoids Ubuntu's unconfined userns restriction.\n userns,\n mount,\n pivot_root,\n\n deny /sys/[^f]*/** wklx,\n deny /sys/f[^s]*/** wklx,\n deny /sys/fs/[^c]*/** wklx,\n deny /sys/fs/c[^g]*/** wklx,\n deny /sys/fs/cg[^r]*/** wklx,\n deny /sys/firmware/** rwklx,\n deny /sys/devices/virtual/powercap/** rwklx,\n deny /sys/kernel/security/** rwklx,\n\n # allow processes within the container to trace each other,\n # provided all other LSM and yama setting allow it.\n ptrace (trace,tracedby,read,readby) peer=tiller-codex-reviewer-v1,\n}\n"
|
|
4
|
+
}
|