Repository Public MIT
1// @vitest-environment node2/**3 * =============================================================================4 * SP BOUCHER | SOFTWARE & RESEARCH5 * ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING6 * =============================================================================7 *8 * Project : VQuant9 * File : server/services/research/sandbox.test.ts10 * Module : server11 * Repository : https://git.spboucher.ai/vquant12 * Project Website : https://vquant.spboucher.ai13 * Created : 2026-11-2014 * Last Modified : 2026-11-2015 *16 * Author : Simon-Pierre Boucher17 * Position : Professor of Finance18 * Institution : Université du Québec en Outaouais (UQO)19 * Organization : SP Boucher20 * Website : https://spboucher.ai21 * Git : https://git.spboucher.ai22 *23 * Preferred Contact: contact@spboucher.ai24 * Development : dev@spboucher.ai25 * Support : support@spboucher.ai26 * Security/Admin : admin@spboucher.ai27 *28 * Copyright (c) 202629 * Simon-Pierre Boucher30 * All rights reserved where applicable. This file is governed by the31 * applicable project license, copyright notices and relevant law.32 * Existing third-party rights and notices remain unaffected.33 *34 * SPDX Identifier : MIT35 * License : MIT License36 * License File : LICENSE37 *38 * Do not embed credentials, private keys, access tokens,39 * certificates or confidential personal information.40 *41 * =============================================================================42 * END OF SP BOUCHER SOURCE HEADER43 * =============================================================================44 */4546/**47 * Adversarial tests of the sandbox and of the egress broker (contract §9.2). They run real Python processes under48 * sandbox-exec; on a platform without it the isolation tests are skipped (and say so), the others still run.49 */50import { afterAll, beforeAll, describe, expect, it } from "vitest";51import fs from "node:fs";52import http from "node:http";53import net from "node:net";54import os from "node:os";55import path from "node:path";56import { pythonPath } from "../python/lab";57import { __stopBroker, brokerUrl, ensureBroker, isPrivateAddress, issueToken, revokeToken } from "./broker";58import { sandboxEnv, sandboxProfile, sandboxStatus, spawnSandboxed, type SandboxLimits } from "./sandbox";5960const enforced = sandboxStatus().enforced;61const SECRET = "sk-test-SUPERSECRET-0123456789abcdef";62let root: string;63let ws: string;64let outside: string;65let port: number;66let decoy: net.Server;67let decoyPort: number;68let upstream: http.Server;69const upstreamSeen: string[] = [];7071beforeAll(async () => {72 root = fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(), "vq-sbx-")));73 ws = path.join(root, "alice", "s-test");74 outside = path.join(root, "bob", "s-other");75 fs.mkdirSync(ws, { recursive: true });76 fs.mkdirSync(outside, { recursive: true });77 fs.writeFileSync(path.join(outside, "secret.txt"), "bob's data");78 fs.writeFileSync(path.join(root, ".env"), `FMP_API_KEY=${SECRET}\n`);79 // The server's own environment holds keys: none of this may reach a child.80 process.env.FMP_API_KEY = SECRET;81 process.env.ANTHROPIC_API_KEY = SECRET;82 process.env.ACCESS_KEY = SECRET;83 process.env.DATABASE_URL = `sqlite://${path.join(root, "local.db")}`;84 fs.writeFileSync(path.join(root, "local.db"), "SQLite format 3\0not really");85 // A stand-in for the FMP API, and a loopback service the sandbox must not reach.86 upstream = http.createServer((req, res) => {87 upstreamSeen.push(req.url ?? "");88 const u = new URL(req.url ?? "/", "http://x");89 if (u.pathname.endsWith("/boom")) return void res.writeHead(401, { "Content-Type": "application/json" }).end(JSON.stringify({ error: `Invalid API KEY ${u.searchParams.get("apikey")}` }));90 res.writeHead(200, { "Content-Type": "application/json" }).end(JSON.stringify([{ symbol: u.searchParams.get("symbol"), price: 123.45 }]));91 });92 await new Promise<void>((r) => upstream.listen(0, "127.0.0.1", () => r()));93 process.env.VQ_FMP_UPSTREAM = `http://127.0.0.1:${(upstream.address() as net.AddressInfo).port}/stable`;94 decoy = net.createServer((s) => s.end("decoy"));95 await new Promise<void>((r) => decoy.listen(0, "127.0.0.1", () => r()));96 decoyPort = (decoy.address() as net.AddressInfo).port;97 port = await ensureBroker();98});99afterAll(async () => {100 await __stopBroker();101 upstream.close();102 decoy.close();103 fs.rmSync(root, { recursive: true, force: true });104});105106interface PyResult {107 out: string;108 err: string;109 code: number | null;110 signal: NodeJS.Signals | null;111 killedFor: string | null;112 ms: number;113}114async function py(code: string, o: { limits?: Partial<SandboxLimits>; network?: "default" | "open"; token?: string | null } = {}): Promise<PyResult> {115 const token = o.token === undefined ? issueToken({ owner: "alice", workspace: ws, network: o.network ?? "default", label: "test" }) : o.token;116 const started = Date.now();117 const s = await spawnSandboxed({ argv: [pythonPath(), "-c", code], workspace: ws, brokerUrl: brokerUrl(port), brokerPort: port, brokerToken: token, limits: { wallMs: 60_000, ...(o.limits ?? {}) } });118 let out = "";119 let err = "";120 s.child.stdout!.on("data", (c) => (out += c));121 s.child.stderr!.on("data", (c) => (err += c));122 const [code_, signal] = await new Promise<[number | null, NodeJS.Signals | null]>((r) => s.child.once("exit", (c, sig) => r([c, sig])));123 revokeToken(token);124 return { out, err, code: code_, signal, killedFor: s.killedFor(), ms: Date.now() - started };125}126/** Runs `body` (which may raise) and prints OK:<repr> or DENIED:<exception class>. */127const attempt = (body: string) => `128import os, sys, socket, subprocess129try:130 r = (lambda: ${body})()131 print("OK:" + repr(r)[:300])132except BaseException as e:133 print("DENIED:" + type(e).__name__ + ":" + str(e)[:200])134`;135136describe("profile and environment (pure)", () => {137 it("gives the child a fixed environment with no server variable in it", () => {138 const env = sandboxEnv({ workspace: ws, scriptsDir: __dirname, brokerUrl: "http://127.0.0.1:1234", brokerToken: "t".repeat(48) });139 expect(JSON.stringify(env)).not.toContain("SUPERSECRET");140 expect(Object.keys(env).some((k) => /ANTHROPIC|OPENAI|ACCESS_KEY|DATABASE|SESSION_SECRET/.test(k))).toBe(false);141 expect(env.FMP_API_KEY).toBe("t".repeat(48));142 expect(env.FMP_BASE_URL).toBe("http://127.0.0.1:1234/fmp");143 expect(env.HOME).toBe(path.join(ws, ".home"));144 expect(env.TMPDIR).toBe(path.join(ws, ".tmp"));145 expect(env.HTTPS_PROXY).toBe(`http://vq:${"t".repeat(48)}@127.0.0.1:1234`);146 expect(env.PYTHONPATH.split(":")[0]).toBe(path.join(ws, ".site"));147 });148149 it("writes a profile that denies by default what matters and re-allows only the workspace and the broker", () => {150 const p = sandboxProfile({ workspace: ws, readOnly: ["/opt/base-venv"], scriptsDir: "/app/dist" }, 4567);151 expect(p).toContain("(deny file-write*)");152 expect(p).toContain('(subpath "/Users")');153 expect(p).toContain(`(allow file-write* (subpath "${ws}")`);154 expect(p).toContain("(deny network*)");155 expect(p).toContain('(allow network-outbound (remote ip "localhost:4567"))');156 expect(p).toContain("(deny signal (target others))");157 expect(p).toContain("(deny mach-lookup)");158 // Only the helper modules of the app directory are readable, not the directory.159 expect(p).toContain('(regex #"^/app/dist/[^/]+\\.py$")');160 expect(p).not.toContain('(subpath "/app/dist")');161 expect(sandboxProfile({ workspace: ws, readOnly: [], scriptsDir: "/app/dist" }, null)).not.toContain("network-outbound");162 });163164 it("classifies private, loopback and link-local addresses", () => {165 for (const ip of ["127.0.0.1", "10.1.2.3", "192.168.2.104", "172.16.0.1", "172.31.255.255", "169.254.169.254", "100.69.26.91", "0.0.0.0", "::1", "fd00::1", "fe80::1", "::ffff:192.168.1.1"]) expect(isPrivateAddress(ip), ip).toBe(true);166 for (const ip of ["1.1.1.1", "151.101.0.223", "172.32.0.1", "100.128.0.1", "2606:4700::1111"]) expect(isPrivateAddress(ip), ip).toBe(false);167 });168});169170describe.skipIf(!enforced)("isolation (sandbox-exec)", () => {171 it("still runs scientific Python and writes in its workspace", async () => {172 const r = await py(`173import numpy as np, pandas as pd, matplotlib174matplotlib.use("Agg")175import matplotlib.pyplot as plt, os176df = pd.DataFrame({"x": np.arange(10.0)})177fig, ax = plt.subplots(); ax.plot(df.x); fig.savefig("artifacts_test.png"); fig.savefig("artifacts_test.svg"); fig.savefig("artifacts_test.pdf")178print("CWD", os.getcwd()); print("SUM", df.x.sum()); print("FILES", sorted(f for f in os.listdir(".") if f.startswith("artifacts_test")))179`);180 expect(r.err).toBe("");181 expect(r.out).toContain(`CWD ${ws}`);182 expect(r.out).toContain("SUM 45.0");183 expect(r.out).toContain("['artifacts_test.pdf', 'artifacts_test.png', 'artifacts_test.svg']");184 }, 60_000);185186 it("holds no credential: environment variables", async () => {187 const r = await py(`import os, json; print(json.dumps(dict(os.environ)))`);188 const env = JSON.parse(r.out);189 expect(r.out).not.toContain("SUPERSECRET");190 expect(Object.keys(env).filter((k) => /ANTHROPIC|OPENAI|GEMINI|ACCESS|DATABASE|SESSION|EODHD|TAVILY|FIRECRAWL|RESEND/.test(k))).toEqual([]);191 expect(env.FMP_API_KEY).toMatch(/^[0-9a-f]{48}$/); // the broker token, not the provider key192 }, 30_000);193194 it.each([195 ["the .env file", `open(${JSON.stringify("PLACEHOLDER_ENV")}).read()`],196 ["the application directory", `os.listdir(${JSON.stringify(process.cwd())})`],197 ["the application's package.json", `open(${JSON.stringify(path.join(process.cwd(), "package.json"))}).read()[:20]`],198 ["the application's .env", `open(${JSON.stringify(path.join(process.cwd(), ".env"))}).read()[:20]`],199 ["the SQLite database", `open(${JSON.stringify("PLACEHOLDER_DB")}, "rb").read(16)`],200 ["another person's workspace", `open(${JSON.stringify("PLACEHOLDER_OTHER")}).read()`],201 ["a listing of another person's workspace", `os.listdir(${JSON.stringify("PLACEHOLDER_OTHERDIR")})`],202 ["~/.ssh", `os.listdir(${JSON.stringify(path.join(os.homedir(), ".ssh"))})`],203 ["the home directory", `os.listdir(${JSON.stringify(os.homedir())})`],204 ["the user's keychains", `os.listdir(${JSON.stringify(path.join(os.homedir(), "Library", "Keychains"))})`],205 ["/tmp", `os.listdir("/tmp")`],206 ])("cannot read %s", async (_what, body) => {207 const code = body.replace("PLACEHOLDER_ENV", path.join(root, ".env")).replace("PLACEHOLDER_DB", path.join(root, "local.db")).replace("PLACEHOLDER_OTHERDIR", outside).replace("PLACEHOLDER_OTHER", path.join(outside, "secret.txt"));208 const r = await py(attempt(code));209 expect(r.out).toMatch(/^DENIED:(PermissionError|FileNotFoundError)/);210 expect(r.out).not.toContain("SUPERSECRET");211 expect(r.out).not.toContain("bob's data");212 }, 30_000);213214 it.each([215 ["the parent of its workspace", () => `open(${JSON.stringify(path.join(root, "alice", "escape.txt"))}, "w").write("x")`],216 ["another person's workspace", () => `open(${JSON.stringify(path.join(outside, "planted.py"))}, "w").write("x")`],217 ["the home directory", () => `open(${JSON.stringify(path.join(os.homedir(), ".vq-sandbox-escape"))}, "w").write("x")`],218 ["/tmp", () => `open("/tmp/vq-sandbox-escape", "w").write("x")`],219 ["the application directory", () => `open(${JSON.stringify(path.join(process.cwd(), "vq-sandbox-escape"))}, "w").write("x")`],220 ["the base environment", () => `open(os.path.join(os.path.dirname(sys.executable), "planted"), "w").write("x")`],221 ["a path reached through a link it creates", () => `(os.symlink(${JSON.stringify(outside)}, "lnk"), open("lnk/planted.txt", "w").write("x"))`],222 ])("cannot write to %s", async (_what, body) => {223 const r = await py(attempt(body()));224 expect(r.out).toMatch(/^DENIED:(PermissionError|FileExistsError|OSError)/);225 for (const f of [path.join(root, "alice", "escape.txt"), path.join(outside, "planted.py"), path.join(outside, "planted.txt"), path.join(os.homedir(), ".vq-sandbox-escape"), "/tmp/vq-sandbox-escape", path.join(process.cwd(), "vq-sandbox-escape")]) expect(fs.existsSync(f), f).toBe(false);226 }, 30_000);227228 it("cannot read through a link to a file outside", async () => {229 const r = await py(attempt(`(os.path.lexists("l2") or os.symlink(${JSON.stringify(path.join(root, ".env"))}, "l2"), open("l2").read())`));230 expect(r.out).toMatch(/^DENIED:PermissionError/);231 }, 30_000);232233 it("has no network: no DNS, no public host, no LAN, no other loopback service", async () => {234 for (const body of [`socket.getaddrinfo("pypi.org", 443)`, `socket.create_connection(("1.1.1.1", 443), timeout=4)`, `socket.create_connection(("192.168.2.1", 80), timeout=4)`, `socket.create_connection(("127.0.0.1", ${decoyPort}), timeout=4).recv(10)`, `socket.socket(socket.AF_INET, socket.SOCK_DGRAM).sendto(b"x", ("8.8.8.8", 53))`, `(lambda s: (s.bind(("0.0.0.0", 0)), s.listen(1)))(socket.socket())`]) {235 const r = await py(attempt(body));236 expect(r.out, body).toMatch(/^DENIED:(PermissionError|gaierror|OSError|TimeoutError)/);237 }238 }, 90_000);239240 it("cannot signal, inspect or drive anything outside the sandbox", async () => {241 const checks: Array<[string, RegExp]> = [242 [`os.kill(${process.pid}, 0)`, /^DENIED:PermissionError/],243 [`os.kill(${process.pid}, 9)`, /^DENIED:PermissionError/],244 [`subprocess.run(["/bin/ps", "eww", "-ax"], capture_output=True, text=True).stdout`, /^(DENIED:PermissionError|OK:'')/],245 [`subprocess.run(["/usr/bin/osascript", "-e", 'tell application "Finder" to get name of home'], capture_output=True, text=True, timeout=20).returncode`, /^(OK:[1-9]|DENIED)/],246 [`subprocess.run(["/usr/bin/open", "-a", "Calculator"], capture_output=True, text=True, timeout=20).returncode`, /^(OK:[1-9]|DENIED)/],247 [`subprocess.run(["/bin/launchctl", "list"], capture_output=True, text=True, timeout=20).returncode`, /^(OK:[1-9]|DENIED)/],248 [`subprocess.run(["/usr/bin/crontab", "-l"], capture_output=True, text=True, timeout=20).returncode`, /^(OK:[1-9]|DENIED)/],249 [`subprocess.run(["/usr/bin/sudo", "-n", "true"], capture_output=True, text=True, timeout=20).returncode`, /^(OK:[1-9]|DENIED)/],250 [`subprocess.run(["/usr/bin/security", "find-generic-password", "-a", "x"], capture_output=True, text=True, timeout=20).returncode`, /^(OK:[1-9]\d*|DENIED)/],251 [`subprocess.run(["/usr/bin/curl", "-sm4", "https://example.com"], capture_output=True, text=True).returncode`, /^(OK:[1-9]\d*|DENIED)/],252 [`subprocess.run(["/usr/bin/ssh", "-o", "BatchMode=yes", "-o", "ConnectTimeout=3", "localhost", "true"], capture_output=True, text=True, timeout=20).returncode`, /^(OK:[1-9]\d*|DENIED)/],253 ];254 for (const [body, expected] of checks) {255 const r = await py(attempt(body));256 expect(r.out, body).toMatch(expected);257 expect(r.out).not.toContain("SUPERSECRET");258 }259 }, 180_000);260});261262describe("resource limits", () => {263 it("stops a run at its wall-clock limit", async () => {264 const r = await py(`import time; print("start", flush=True); time.sleep(60)`, { limits: { wallMs: 2500 } });265 expect(r.killedFor).toMatch(/time limit/);266 expect(r.ms).toBeLessThan(15_000);267 }, 30_000);268269 it("stops a memory hog", async () => {270 const r = await py(`271import time272blocks = []273for i in range(400):274 blocks.append(bytearray(16 * 1024 * 1024)) # 16 MB, zero-filled: resident275 time.sleep(0.02)276print("survived")277`, { limits: { memoryMb: 400 } });278 expect(r.out).not.toContain("survived");279 expect(r.killedFor).toMatch(/memory limit: \d+ MB resident for a limit of 400 MB/);280 }, 60_000);281282 it("stops a fork bomb", async () => {283 const r = await py(`284import subprocess, sys, time285kids = []286for i in range(300):287 kids.append(subprocess.Popen([sys.executable, "-c", "import time; time.sleep(60)"], start_new_session=(i % 2 == 0)))288 time.sleep(0.03)289print("survived", len(kids))290`, { limits: { maxProcesses: 12 } });291 expect(r.out).not.toContain("survived");292 expect(r.killedFor).toMatch(/process limit: \d+ processes for a limit of 12/);293 // Nothing of the tree is left behind, including the children that started their own session.294 await new Promise((res) => setTimeout(res, 1500));295 const left = await py(`print("ok")`);296 expect(left.out).toContain("ok");297 }, 90_000);298299 it("stops a CPU burner at its CPU-time limit", async () => {300 const r = await py(`301x = 0302while True:303 x += 1304`, { limits: { cpuSeconds: 2, wallMs: 40_000 } });305 expect(r.killedFor).toBeNull(); // the kernel did it (SIGXCPU), not the watchdog306 expect(r.signal === "SIGXCPU" || r.code !== 0).toBe(true);307 expect(r.ms).toBeLessThan(20_000);308 }, 45_000);309310 it("refuses a file larger than the limit, and a workspace larger than its quota", async () => {311 const big = await py(attempt(`open("big.bin", "wb").write(b"\\0" * (30 * 1024 * 1024))`), { limits: { fileMb: 5 } });312 expect(big.out.startsWith("OK:")).toBe(false);313 const size = fs.existsSync(path.join(ws, "big.bin")) ? fs.statSync(path.join(ws, "big.bin")).size : 0;314 expect(size).toBeLessThanOrEqual(5 * 1024 * 1024);315 fs.rmSync(path.join(ws, "big.bin"), { force: true });316317 const quota = await py(`318import time319for i in range(200):320 open(f"chunk_{i}.bin", "wb").write(b"\\1" * (4 * 1024 * 1024))321 time.sleep(0.15)322print("survived")323`, { limits: { diskMb: 60, wallMs: 60_000 } });324 expect(quota.out).not.toContain("survived");325 expect(quota.killedFor).toMatch(/disk limit/);326 for (const f of fs.readdirSync(ws)) if (f.startsWith("chunk_")) fs.rmSync(path.join(ws, f));327 }, 90_000);328});329330describe("egress broker", () => {331 const get = (p: string, headers: Record<string, string> = {}) => fetch(`${brokerUrl(port)}${p}`, { headers });332333 it("serves nothing without a valid token", async () => {334 expect((await get("/fmp/quote?symbol=AAPL")).status).toBe(401);335 expect((await get("/fmp/quote?symbol=AAPL&apikey=wrong")).status).toBe(401);336 expect((await get("/health", { "X-VQ-Token": "0".repeat(48) })).status).toBe(401);337 const t = issueToken({ owner: "alice", workspace: ws, network: "default" });338 expect((await get("/health", { "X-VQ-Token": t })).status).toBe(200);339 revokeToken(t);340 expect((await get("/health", { "X-VQ-Token": t })).status).toBe(401);341 });342343 it("adds the provider key on the server side and never returns it", async () => {344 const t = issueToken({ owner: "alice", workspace: ws, network: "default" });345 const ok = await get(`/fmp/quote?symbol=AAPL&apikey=${t}`);346 expect(ok.status).toBe(200);347 expect(await ok.json()).toEqual([{ symbol: "AAPL", price: 123.45 }]);348 expect(upstreamSeen.at(-1)).toContain(`apikey=${SECRET}`);349 expect(upstreamSeen.at(-1)).not.toContain(t);350 // An upstream error that echoes the key comes back masked.351 const bad = await get(`/fmp/boom?apikey=${t}`);352 expect(bad.status).toBe(401);353 const text = await bad.text();354 expect(text).not.toContain("SUPERSECRET");355 expect(text).toContain("[redacted]");356 expect((await fetch(`${brokerUrl(port)}/fmp/quote?apikey=${t}`, { method: "POST" })).status).toBe(405);357 expect((await get(`/fmp/../admin?apikey=${t}`)).status).toBeGreaterThanOrEqual(400);358 revokeToken(t);359 });360361 it.skipIf(!enforced)("lets sandboxed code fetch market data through it without holding the key", async () => {362 const r = await py(`363import os, json, urllib.request364url = os.environ["FMP_BASE_URL"] + "/quote?symbol=MSFT&apikey=" + os.environ["FMP_API_KEY"]365opener = urllib.request.build_opener(urllib.request.ProxyHandler({}))366print(opener.open(url, timeout=20).read().decode())367`);368 expect(r.err).toBe("");369 expect(JSON.parse(r.out)).toEqual([{ symbol: "MSFT", price: 123.45 }]);370 expect(r.out).not.toContain("SUPERSECRET");371 }, 30_000);372373 const connect = (target: string, token: string | null) =>374 new Promise<string>((resolve) => {375 const s = net.connect(port, "127.0.0.1", () => s.write(`CONNECT ${target} HTTP/1.1\r\nHost: ${target}\r\n${token ? `Proxy-Authorization: Basic ${Buffer.from(`vq:${token}`).toString("base64")}\r\n` : ""}\r\n`));376 let buf = "";377 s.on("data", (c) => {378 buf += c;379 if (buf.includes("\r\n")) {380 resolve(buf.split("\r\n")[0]);381 s.destroy();382 }383 });384 s.on("error", () => resolve("error"));385 setTimeout(() => (resolve(buf.split("\r\n")[0] || "timeout"), s.destroy()), 15_000);386 });387388 it("proxies only the package index by default, and logs what it refuses", async () => {389 const t = issueToken({ owner: "alice", workspace: ws, network: "default", label: "t" });390 expect(await connect("example.com:443", null)).toMatch(/ 407 /);391 expect(await connect("example.com:443", t)).toMatch(/ 403 /);392 expect(await connect("evil.pypi.org.example.com:443", t)).toMatch(/ 403 /);393 expect(await connect("pypi.org:22", t)).toMatch(/ 403 /);394 expect(await connect(`127.0.0.1:${decoyPort}`, t)).toMatch(/ 403 /);395 expect(fs.readFileSync(path.join(ws, "logs", "network.log"), "utf8")).toContain("DENIED example.com:443");396 revokeToken(t);397 });398399 it("never reaches a private or loopback address, even in an approved open-network run", async () => {400 const t = issueToken({ owner: "alice", workspace: ws, network: "open", label: "open" });401 expect(await connect("127.0.0.1:443", t)).toMatch(/ 403 /);402 expect(await connect("192.168.2.104:443", t)).toMatch(/ 403 /);403 expect(await connect("169.254.169.254:80", t)).toMatch(/ 403 /);404 expect(await connect("localhost:443", t)).toMatch(/ 403 /);405 expect(fs.readFileSync(path.join(ws, "logs", "network.log"), "utf8")).toContain("DENIED-PRIVATE");406 revokeToken(t);407 });408409 it.skipIf(!enforced || process.env.VQ_TEST_OFFLINE === "1")("reaches the package index through the proxy from inside the sandbox, and nothing else", async () => {410 const r = await py(`411import urllib.request412def get(u):413 try:414 return urllib.request.urlopen(u, timeout=25).status415 except Exception as e:416 return type(e).__name__ + ":" + str(e)[:80]417print("PYPI", get("https://pypi.org/simple/pip/"))418print("OTHER", get("https://example.com/"))419`);420 expect(r.out).toContain("PYPI 200");421 expect(r.out).toMatch(/OTHER (URLError|OSError|HTTPError).*403/);422 }, 60_000);423});424