feat(sandbox): 不可信字节在沙箱子进程里解析(撤销权限、超时与内存强杀);种子、文件预览、字幕解析迁入
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
1a76d2d700
commit
eeec91e892
21 files changed
+632
-178
No files matched your search
@@ -12,6 +12,8 @@ import type { MappingExport } from "./ops.ts";
|
||||
// (逐行事务、幂等可重跑;步骤与回滚见 docs/runbook/auth.md)
|
||||
// fsworker fsproxy 执行子进程(编译二进制里由 fsproxy 以
|
||||
// `<自身> --role fsworker` 拉起,stdin 一条请求)
|
||||
// sandbox 沙箱子进程(src/sandbox:撤销全部权限后解析不可信
|
||||
// 字节,stdin 一条请求,stdout 一条结果)
|
||||
const Roles = [
|
||||
"api",
|
||||
"worker",
|
||||
@@ -24,6 +26,7 @@ const Roles = [
|
||||
"read-only-on",
|
||||
"rotate-master-key",
|
||||
"fsworker",
|
||||
"sandbox",
|
||||
] as const;
|
||||
type Role = (typeof Roles)[number];
|
||||
const OneShot = ["migrate", "preflight", "export-mappings", "read-only-on", "rotate-master-key"] as const;
|
||||
@@ -53,6 +56,13 @@ if (role === "fsworker") {
|
||||
Deno.exit(0);
|
||||
}
|
||||
|
||||
// 沙箱子进程:同样在加载其余模块前分派,只加载沙箱任务表
|
||||
if (role === "sandbox") {
|
||||
const { sandboxWorkerMain } = await import("./sandbox/worker.ts");
|
||||
await sandboxWorkerMain();
|
||||
Deno.exit(0);
|
||||
}
|
||||
|
||||
// 健康探测:只打本机回环端口,不需要完整配置(HEALTHCHECK 用,镜像里不装 curl)
|
||||
if (role === "probe") {
|
||||
const port = Deno.env.get("PORT") ?? "4380";
|
||||
@@ -78,6 +88,9 @@ const { diffCounts, enableReadOnlyReconcile, exportMappings, writeMappingExport
|
||||
const { auditStorageWarnings, checkStorage, loadMountedPaths, runPreflight } = await import("./preflight.ts");
|
||||
const { startWorker } = await import("./worker/index.ts");
|
||||
const { laneOverridesFromEnv } = await import("./worker/lanes.ts");
|
||||
const { installSandboxParsers } = await import("./sandbox/install.ts");
|
||||
// 不可信字节(种子等)的解析改走沙箱子进程;一次性子命令也装上,无副作用
|
||||
installSandboxParsers();
|
||||
|
||||
let config: Config;
|
||||
try {
|
||||
|
||||
Reference in new issue
Block a user