部署:bubblewrap 沙箱、编译检查、访问口令、Docker Compose
- 学生程序每次运行放进 bubblewrap:断网,只读挂载系统文件、运行时和自己的工程目录, 看不到其他进程和服务器环境变量;限制堆内存 128 MB、CPU 时间 120 秒、运行 60 分钟, nice 10,全站同时运行上限 150;启动时自检沙箱,不可用时拒绝运行 - 编译检查(SIM001):网络、反射、启动进程、调用本机代码、加载程序集、dynamic 给出中文报错 - 访问口令:cookie 保存口令哈希,按真实 IP 限制输错次数;前端口令页 - 服务端配置集中到 config.ts,可用环境变量覆盖;Bun 直接提供打包好的网页 - Dockerfile(多阶段,服务端打包成单文件)、compose.yaml(Caddy 只收 HTTP,接入 NPM 的 npm_proxy 网络)、deploy/deploy.sh(本机构建后经 ssh 传到服务器)和部署说明 - 测试:沙箱隔离、内存上限、CPU 时间上限、编译检查 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
081ac6f924
commit
697f31e9ce
25 files changed
+869
-52
No files matched your search
+3
-2
@@ -5,7 +5,8 @@ import { cp, mkdir, rm } from 'node:fs/promises'
|
||||
import { resolve } from 'node:path'
|
||||
import type { ControlNode, RunnerMessage } from '@iot/shared'
|
||||
import { compileService } from '../src/compile-service'
|
||||
import { ROOT, RUNNER_DLL, readLines } from '../src/runner-process'
|
||||
import { config, ROOT } from '../src/config'
|
||||
import { readLines } from '../src/runner-process'
|
||||
|
||||
const COUNT = Number(process.argv[2] ?? 100)
|
||||
const dir = resolve(ROOT, '.runs/load-test')
|
||||
@@ -47,7 +48,7 @@ const startAt = performance.now()
|
||||
const instances: Instance[] = []
|
||||
const shown: Promise<void>[] = []
|
||||
for (let i = 0; i < COUNT; i++) {
|
||||
const proc = Bun.spawn(['dotnet', RUNNER_DLL, 'run', dir], { stdin: 'pipe', stdout: 'pipe', stderr: 'inherit' })
|
||||
const proc = Bun.spawn(['dotnet', config.runnerDll, 'run', dir], { stdin: 'pipe', stdout: 'pipe', stderr: 'inherit' })
|
||||
const instance: Instance = { proc }
|
||||
instances.push(instance)
|
||||
shown.push(
|
||||
|
||||
Reference in new issue
Block a user