iOS sandbox: a worker setting boots every leased simulator sandboxed and checked
维护者通常 1 天内回复
评估
这个 Issue 还没有评估数据。
描述
Part of #1648.
Scope
An operator turns on ios.sandbox.enabled on a worker: from then on every simulator that worker leases boots sandboxed and is checked before it is granted; one that fails is never leased. agent-device's boots on that worker are sandboxed too. A worker on an unchecked Mac, Xcode or device set refuses iOS and says why. A leased simulator found without the sandbox loses its lease. Without the setting nothing changes.
If it goes wrong, a sandboxed worker grants an unsandboxed simulator, or a worker without the setting boots or refuses differently than today.
Technical spec
Commit b037ae2a0.
Rows
- Behaviours: B3, B4, B5, B6, B7, B15, B18
- Stored state: S1, S2, S3
- Interfaces: I15, I17, I2, I3, I4, I5, I6, I7, I14
- Existing code: X1, X2, X3, X4, X5, X6, X7, X8, X9, X14, X17, X18, X23, X24, X25
Facts
none
Modules touched
drivers/ios (definition.ts, driver-options.ts, simulator-boot.ts, command-run.ts, index.ts, seeds.ts lookup, new jail-profile.ts, jail-platform.ts, jail-xcrun.ts, jail/profile.sb, jail/main.swift for I15, jail/Jail.swift for I3: SIMLOCK_JAIL_DIR, the profile and token found by SIMULATOR_UDID, in place of the prototype's SIMLOCK_JAIL_PROFILE and SIMLOCK_JAIL_TOKEN), core (driver.ts, startup-converger.ts, create-core.ts:423 where the converger's ports are built, managed-device-lifecycle.ts tests), leasing (lease-health-monitor.ts), daemon (driver-discovery.ts, worker-composition.ts), bus (src/bus/index.ts EventMap and EVENT_NAMES, index.test.ts) for driver.sandbox-rejected, agent-device (host/agent-device-supervisor.ts, worker.ts), e2e/slow-ios-sandbox.test.ts (new), website (reference/configuration.mdx, reference/events.mdx, troubleshooting/worker.mdx), docs/internal/EVENTS.md, src/drivers/ios/AGENTS.md, docs/internal/agent-rules/toolchain.md "The simulator jail" (its check steps use the new variables). Searches: rg "bootAndWait|virtualLeaseEnvironment|driverEnvironment|DriverRejection|IdleDeviceDeletion|launchd_sim" src.
Rules in play
- ADR 0103 (Accepted — not yet implemented): the sections named on each line below; the feature's rows hold the shapes.
- ADR 0103 §1–§4: per worker, off by default; every lease boot sandboxed and checked, fail closed; the kill block; checked platforms only.
- ADR 0001 and 0048 as 0103 narrows them: the
defaultset is refused with the sandbox on. src/drivers/AGENTS.md: the driver imports only core, ports andshared; facts reach the bus through callbacks (the new event throughdriver-discovery.ts).src/agent-device/AGENTS.md: the edge imports nothing from the drivers; thexcrunfolder reaches it asdriverEnvironmentonly.src/core/AGENTS.md: the new deletion port commits throughRegistry; startup never installs.- Documentation rule 9: configuration, events and troubleshooting pages in this PR.
Tests
Seams: createDriver with a ScriptedProcessRunner (src/drivers/ios/test-index.ts:217, model src/drivers/ios/index-device-set.test.ts), src/drivers/ios/definition.test.ts, src/leasing/lease-health-monitor.test.ts, src/core/startup-converger.test.ts, src/agent-device/host/agent-device-supervisor.test.ts, src/core/create-core.test.ts (the deletion adapter), src/daemon/main-agent-device.test.ts (the agentDeviceEnvironment to PATH wiring) and src/daemon/driver-discovery.test.ts (the driver.sandbox-rejected payload) (seams added in delivery, pending the maintainer).
- B3: An operator sets
ios.sandbox; the config loadsenabled(defaultfalse) andreversePorts(default list), and refuses a bad value withinvalid value for ios.sandbox.<key>: absent;enabled: true;enabled: "yes";reversePorts: [];[8081, 8081];[0];[70000];[80.5];["8081"]; 201 ports - B3a: a refused
ios.sandboxvalue throws the message every other config key throws,Invalid config value for "ios.sandbox.<key>": expected …, andreversePorts: [8081, 8081]loads as[8081](I4: duplicates kept once); the B3 test pins both (decided in delivery, pending the maintainer) - B4: On a worker without the sandbox, every boot runs
simctl bootwith noSIMCTL_CHILD_key, compiles nothing, checks nothing, andlistManagedruns no check: prepare boot; recovery boot; reboot before a grant (default set); clipboard refresh reboot;listManaged - B5: A sandboxed worker's iOS driver does not start when the Mac is not Apple silicon, the macOS or Xcode major is not checked or not readable, the jail files are missing or
drivers.ios.deviceSetisdefault(whichios.simulator.headless: falseneeds, so it is refused too);driver.sandbox-rejectedis emitted with the reason and doctor lists its summary; Android starts: arm64 + checked majors: starts;hw.optional.arm64prints 0:not-apple-silicon;sysctlexits non-zero (no such key):not-apple-silicon;sw_vers -productVersion27.0:unchecked-macos;sw_versfails:unchecked-macos(unreadable); Xcode 28:unchecked-xcode;xcodebuild -versionfails:unchecked-xcode(unreadable); nodist/jail/simlock-jail:missing-files;deviceSet: defaultwithheadless: falseortrue:device-set;headless: falseon the simlock set:invalid-device-set, as today (Simulator.app, which agent-device opens after each boot it makes,v0.21.43:packages/platform-apple/src/core/simulator.ts:187, sees Xcode's set and can boot a simulator without the sandbox) - B6: On a sandboxed worker each lease boot writes the simulator's profile (shipped
profile.sbplus one port pair per listed port), compiles it into its jail folder, empties its grants file, deletes its acknowledgement file, writes its token file, then runssimctl bootwith the jail's twoSIMCTL_CHILD_keys (I3); seed throwaway and settle boots carry none: prepare; recover; reboot before a grant; seed throwaway; settle copy; emptyreversePorts(no pair) - B7: After a sandboxed boot the driver finds the simulator's root
launchd_sim(X14), records its pid as the boot's identity (X4), and runssimlock-jail checkon it and every live process under it; a process that has exited by the check is skipped; on exit 0 the device is ready, otherwise the driver shuts the simulator down and the boot fails with I7; a failed lease boot destroys the device, a failed recovery boot is retried and in the end loses the lease: check exits 0; check exits 1; a child gone betweenpsand the check (skipped, exit 0); root gone (exit 1); no rootlaunchd_sim; a process namedlaunchd_simwhose command names the device folder but whose program is another file, under the root or orphaned to pid 1 with a lower pid (not taken as root);lsoffails for a candidate (not taken);simlock-jailpast 10 s;compileexits 65 (boot fails beforesimctl boot); recover boot fails the check (simulator shut down, error rethrown) - B15: On a sandboxed worker the iOS
listManagedchecks each running simulator and marks one whose rootlaunchd_simis not sandboxed; the health monitor ends a leased one's lease as lost (device.recovery-failed, reasonunsandboxed) without a recovery attempt, and startup converge deletes an unleasedreadyone that its startup listing markedsandboxed: false, through a port of its own (UnsandboxedDeviceDeletion.deleteUnsandboxed, besideIdleDeviceDeletioninsrc/core/startup-converger.ts:27; recorddeleted, the events a delete commits today), and no other device; when a sandboxed simulator is deleted the driver first lists the processes whose program lies in its device folder and, after the delete, kills those still running, because a copy oflaunchd_simrun from there keeps Apple's signature and cannot be killed from inside: leased, sandboxed: nothing; leased, not sandboxed: lease lost, device reclaimed (deleted); ready, not sandboxed at startup: deleted (recorddeleted); ready and shutdown devices marked sandboxed, or not marked: kept; a process running a copy oflaunchd_simfrom the device folder after the delete: killed; check fails to run: not marked (no evidence); without the sandbox: no check - B18: On a sandboxed worker agent-device's simulator daemon runs
xcrunthrough simlock'sxcrun(I17): everysimctlcall carries the jail's two keys, so a plainsimctl boot <udid>(agent-device'sensureBootedSimulator, v0.21.43packages/platform-apple/src/core/simulator.ts:64-115) boots sandboxed, andsimctl bootstatus <udid> -bbecomessimctl bootwith the keys, thenbootstatus <udid>without-b;xcodebuild(throughPATHorxcrun xcodebuild) boots a shut-down destination with the keys first; other calls pass on unchanged; without the sandbox the daemon'sPATHis as today:simctl boot <udid>: the keys present;simctl --set <set> boot <udid>:--setkept, keys present;bootstatus <udid> -b:bootwith the keys thenbootstatus <udid>;bootexits non-zero "already booted": goes on tobootstatus;bootfails otherwise: its exit code, nobootstatus;simctl --set <set> bootstatus <udid> -b: the--setkept on both;simctl launch …,simctl list: keys present, arguments unchanged;xcodebuild … -destination id=<udid> -DVTSimulatorSetLocation=<set>with the simulatorShutdownin that set:simctl --set <set> boot <udid>with the keys, then the realxcodebuildwith the same arguments; that boot fails: its exit code, the realxcodebuildnot run; same with itBooted: no boot;xcrun xcodebuild …: the same;xcodebuildwith no simulator destination: unchanged;PATHof the simulator daemon: the wrapper folder then the oldPATH; phone daemon: unchanged; without the sandbox: no wrapper onPATH - B6a: the clipboard-refresh second boot runs only on the
defaultset, which a sandboxed worker refuses (B5), so it is not a sandboxed boot: it passes no jail key and B6 has no case for it (decided in delivery, pending the maintainer) - B15a:
unsandboxedDeletioninsrc/core/create-core.tsshuts the device down, then destroys it with initiatorunsandboxed; a failed delete is logged, not thrown;create-core.test.tspins both (decided in delivery, pending the maintainer) - B19:
src/drivers/ios/AGENTS.mdis at its 8000-character cap, so it gains one short line pointing to ADR 0103 for the sandbox rules (the kill after a delete, thexcrunfolder), with existing lines reworded, not dropped, to make room;src/docs-manuals.repo.test.tsstays green (decided in delivery, pending the maintainer)
Done when
- Every unit case of B3–B7, B15, B18 passes; a worker without
ios.sandboxkeeps today's argv for every boot (B4). website/src/content/docs/docs/reference/configuration.mdxdocumentsios.sandbox,events.mdxdocumentsdriver.sandbox-rejectedand theunsandboxedreason,troubleshooting/worker.mdxeach refusal.- Slow lane (real simulator):
e2e/slow-ios-sandbox.test.ts(new) leases a simulator on a sandboxed worker,simlock-jail checkpasses for its rootlaunchd_sim, and an app in it is refused the worker's home folder; the same test confirms agent-device's simulator daemon finds simlock'sxcrunonPATH(I17).
Out of scope
The simctl allow-list (T3), port grants and the peer check (T4), the lease-folder grant (T5), the docs page on what the sandbox covers (T6).
Depends on
- #2048 because:
dist/jail/andsrc/drivers/ios/jail/
Written by an agent.
- 主要语言
- TypeScript
- 星标
- 730
- 派生
- 44
- 平均合并
- 15 小时 28 分钟
- 30 天内合并 PR
- 387
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
callstackincubator/simlock 的其他 Issue
-
bug:new
难度 2/5 1-3 小时 新手友好度 73/100
callstackincubator/simlock#2088 ·
维护者通常 1 天内回复
-
bug:new
难度 2/5 1-3 小时 新手友好度 64/100
callstackincubator/simlock#2080 · 1 条评论 ·
维护者通常 1 天内回复
-
task:ready
难度 4/5 3-5 天 新手友好度 52/100
callstackincubator/simlock#2079 ·
维护者通常 1 天内回复
-
platform:ios task:ready
难度 5/5 一周以上 新手友好度 18/100
callstackincubator/simlock#2078 ·
维护者通常 1 天内回复
-
iOS copy: keep the app database at the copy's own UDID可能已有人在做 @V3RON 今天认领。 未关闭platform:ios task:ready
callstackincubator/simlock#2077 · 2 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
查看 callstackincubator/simlock 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 74/100
melgarafael/DeskcommCRM#5614 · 1 条评论 ·
维护者通常 1 天内回复
-
documentation
难度 1/5 1 小时以内 新手友好度 76/100
slackapi/slack-health-score#253 ·
维护者通常 1 天内回复
-
feature needs triage site
难度 2/5 1-3 小时 新手友好度 64/100
owid/owid-grapher#8019 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
simstudioai/sim#10710 ·
维护者通常 1 天内回复
-
via-triage
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复