Repository navigation
ci(ssh): macOS SSH-host lane for the pinned relay; fix uploads under a symlinked root - #24179
Conversation
|
| await waitForNoProcessMatching(target.tempDir, 5_000) | ||
| } | ||
| await rm(target.tempDir, { recursive: true, force: true }) |
There was a problem hiding this comment.
Cleanup can delete live runtime If a relay process remains after both termination attempts, the second process check can return false, but cleanup still deletes its temporary home. This can remove runtime and log files beneath a live process and make a failed macOS cell harder to diagnose. Keep the files until process exit is confirmed, and report unsuccessful cleanup.
Knowledge Base Used: Restore bounded SSH relay lsof probes
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — the full 3-commit PR against OrcaWin/node-rt-p2-hostile.
- SFTP upload root resolution —
uploadDirectorynow resolves its root once before entries are compared by realpath, so a root under a symlinked parent (macOS/var → /private/var) no longer rejects its own children as escapes; the recursive body moved touploadDirectoryWithincarrying the resolved root. - macOS hostile-host lane — new
macos_hostsworkflow job runs each macOS runner (macos-14 arm64, macos-15-intel x64) against its own user-level loopback sshd, builds that runner's darwin slot/template/relay, and addssrc/main/ssh/sftp-*to the trigger paths. - Local-sshd harness —
ssh-hostile-host-local-sshd.tsstarts a pubkey-only sshd withPATHcut to the toolchain shims, probes the SSH exec channel to prove no host toolchain ornodeleaks, and cleans up sshd plus the daemonised relay by temp-dir match. - Cell selection guard —
HostileHostCellis split into Docker and local-sshd variants;selectHostileHostCellsnow fails a run that names a cell the machine cannot host instead of silently skipping it, and a test asserts at least one cell was selected. - Shared shim — the forbidden-tool shim is factored into
forbiddenToolShimScript(logPath)and reused by both targets; observers andstatidentity probes split by host OS.
I verified the fix against the prior implementation and all in-repo callers: every caller already passes the upload directory as its own root, so resolving it once is idempotent while closing the symlinked-parent gap, and the sibling-escape rejection test still holds. Targeted tests, pnpm tc:node, and oxlint on the changed files all pass. The author already flags that the GitHub macOS runners and the darwin-x64 cell are unexercised.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
4dfbd08 to
4fad278
Compare
84e5df5 to
e0c6946
Compare
The upload-root realpath fix landed with #24180; this keeps macoshost's case where the root is passed explicitly beneath a symlinked parent.
Adds local-sshd cells for darwin-arm64 (macos-14) and darwin-x64 (macos-15-intel): a non-root sshd on 127.0.0.1 logs in as the runner user with SetEnv PATH=<shims>:/usr/bin:/bin:/usr/sbin:/sbin and an empty HOME, so no rc file restores Homebrew. The driver asserts rung A, terminal echo, cached runtime reuse, GC keeping the in-use runtime, no toolchain or xattr calls, and that the SFTP-uploaded Node carries no quarantine and runs as uploaded. Docker cells are unchanged; each machine runs only cells it can host.
…table cell A cell named for the wrong OS or arch was silently skipped, so a macOS job on a mismatched runner went green having deployed nothing. Named cells must now be hostable here, and a gated run must select at least one cell.
e0c6946 to
31f9f2f
Compare
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. 🧰 Additional context used📚 Code guidelines (1)📝 WalkthroughWalkthroughThe hostile-host matrix now includes macOS arm64 and x64 local SSH targets. Target selection checks host platform and architecture, and the fixture supports both Docker and local SSH targets. The workflow builds and tests the matching macOS targets. The hostile-host tests add local-target checks, and a separate SFTP test covers uploads through a symlinked parent. Priority: ⬇️ Low Merge Risk: 🔵 Low · up to The macOS test target can leave processes and temporary files behind if sshd stalls during shutdown. This is a narrow test-cleanup risk; merge with owner awareness, preferably after bounding the termination wait. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The new SSH service is restricted to loopback and generated keys, with temporary test state and read-only repository permissions. Its shutdown path does not guarantee complete cleanup after a termination failure, but the supported exposure is limited to the test runner. Retained concerns
Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 33 functions across 8 files. (1 skipped: 1 unsupported.)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 598eb6e7-e0c4-4ca6-b1b5-4d10ade8f842
📒 Files selected for processing (9)
.github/workflows/ssh-hostile-hosts.ymlconfig/scripts/ssh-hostile-hosts-workflow.test.mjssrc/main/ssh/sftp-upload.test.tssrc/main/ssh/ssh-hostile-host-cells.test.tssrc/main/ssh/ssh-hostile-host-cells.tssrc/main/ssh/ssh-hostile-host-local-sshd.test.tssrc/main/ssh/ssh-hostile-host-local-sshd.tssrc/main/ssh/ssh-hostile-host-test-fixture.tssrc/main/ssh/ssh-relay-hostile-hosts.docker.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.
| export async function stopLocalSshdTarget(target: LocalSshdHostileHostTarget): Promise<void> { | ||
| if (target.sshd.exitCode === null && target.sshd.signalCode === null) { | ||
| const exited = new Promise((resolve) => target.sshd.once('exit', resolve)) | ||
| target.sshd.kill('SIGTERM') | ||
| await exited | ||
| } |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
sed -n '95,215p' src/main/ssh/ssh-hostile-host-local-sshd.ts
sed -n '90,115p' src/main/ssh/ssh-hostile-host-test-fixture.ts
sed -n '65,145p' src/main/ssh/ssh-relay-hostile-hosts.docker.test.tsRepository: stablyai/orca
Length of output: 7743
Bound the sshd termination wait.
stopLocalSshdTarget waits indefinitely for the managed sshd process to emit exit after sending SIGTERM. A stopped or stalled sshd can remain alive and prevent relay cleanup and temporary-directory removal until the outer test hook times out. Keep the normal SIGTERM path, but use a bounded wait and send SIGKILL when the wait expires.
Suggested fix
- const exited = new Promise((resolve) => target.sshd.once('exit', resolve))
+ const exited = new Promise((resolve) => target.sshd.once('exit', resolve))
target.sshd.kill('SIGTERM')
- await exited
+ const timedOut = await Promise.race([
+ exited.then(() => false),
+ new Promise<boolean>((resolve) => setTimeout(() => resolve(true), 10_000))
+ ])
+ if (timedOut) {
+ target.sshd.kill('SIGKILL')
+ await exited
+ }📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| export async function stopLocalSshdTarget(target: LocalSshdHostileHostTarget): Promise<void> { | |
| if (target.sshd.exitCode === null && target.sshd.signalCode === null) { | |
| const exited = new Promise((resolve) => target.sshd.once('exit', resolve)) | |
| target.sshd.kill('SIGTERM') | |
| await exited | |
| } | |
| export async function stopLocalSshdTarget(target: LocalSshdHostileHostTarget): Promise<void> { | |
| if (target.sshd.exitCode === null && target.sshd.signalCode === null) { | |
| const exited = new Promise((resolve) => target.sshd.once('exit', resolve)) | |
| target.sshd.kill('SIGTERM') | |
| const timedOut = await Promise.race([ | |
| exited.then(() => false), | |
| new Promise<boolean>((resolve) => setTimeout(() => resolve(true), 10_000)) | |
| ]) | |
| if (timedOut) { | |
| target.sshd.kill('SIGKILL') | |
| await exited | |
| } | |
| } |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — delta since the prior pullfrog review (84e5df54c0): the branch was rebased from the stacked base onto current main, and the new commits rework the driver to adopt main's shared hostile-host harness and observer instead of the PR-local inline helpers.
- Adopted the shared harness —
ssh-relay-hostile-hosts.docker.test.tsandssh-hostile-host-test-fixture.tsnow usessh-hostile-host-test-harness.ts(deployOnce/assertCell/exerciseLaunchedCell) andssh-hostile-host-observer.ts(localHostObserver), dropping the PR-localhostileHostOs/fileIdentityCommandsplit and the inline deploy helpers. legacy_opt_outin the driver — the non-launched branch now skips the refusal assertion for opted-out cells (cell.expect.outcome !== 'legacy_opt_out').- Unchanged from the prior review — the Docker/local-sshd cell union, machine-aware
selectHostileHostCells,forbiddenToolShimScript, themacos_hostslane, the at-least-one-cell guard, and the symlinked-parent upload test all carry over intact.
pnpm tc:node is clean and the four targeted suites pass (32 tests).
ℹ️ PR body still describes a prod fix that is no longer in the diff
The "What Changed" section tells a reviewer to look at a bug fix in src/main/ssh/sftp-upload.ts, but that file is not part of this PR's diff against main — the fix already landed there, and this PR now carries only the regression test. Updating the body avoids a reviewer hunting for a prod change that isn't in the PR.
Technical details
# PR body advertises a prod change absent from the diff
## Affected sites
- `src/main/ssh/sftp-upload.ts` — unchanged in this PR; `git diff --stat 0ad77ea2f7..HEAD -- src/main/ssh/sftp-upload.ts` is empty.
- PR body, "What Changed" bullet `**Bug fix**` (`sftp-upload.ts`) — describes a change not present here.
## Required outcome
- Body describes what this PR actually changes, or notes that the SFTP fix already landed on `main` and this PR carries only the regression test.
## Open questions for the human (optional)
- Is the stale text intentional (the PR is a rebase of a stacked branch), or should the body be refreshed?DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

ELI5
This adds a CI test that uses a macOS runner as the SSH host. It runs its own SSH server with no Node, npm or compiler on the SSH path, and checks that Orca's pinned Node relay works on it. The test found and fixes a real upload bug: uploads failed whenever the source folder sat under a symlink, and on macOS
/varis one.What Changed
sftp-upload.ts):uploadDirectorycompared each file's resolved path against an unresolved root, so any file under a symlinked parent looked like it escaped the root. The root is now resolved once, and a test covers a symlinked parent.ssh-hostile-hosts.ymljobmacos_hosts, on macos-14 and macos-15-intel):/usr/sbin/sshdlistens on loopback, with no sudo and no system changes.SetEnvsets a PATH with no Node or Homebrew, and logging stand-ins replace npm, node-gyp, compilers andxattr.Why
This covers the macOS part of the Phase 2 exit gate, on CI runners rather than a shared machine.
Linked Issue
Part of the Node runtime plan (Phase 2). Stacked on #24146.
Visual Proof
N/A. This is CI plus a bug fix.
Testing
Passed end to end on a local Mac (macOS 26.6.2 arm64): rung A, then a second connect with
runtimeTransfer=cached.2,976 SSH tests pass.
Not yet run:
com.apple.access_ssh;Can't be hidden: the SIP-protected
/usr/bin/ccstubs, which are shadowed on PATH but not removed.I manually tested these changes locally
Automated tests added/updated, or explained why not below
Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.