feat(cli): add spawn link command to reconnect existing deployments#2675
feat(cli): add spawn link command to reconnect existing deployments#2675
Conversation
louisgv
left a comment
There was a problem hiding this comment.
Security Review
Verdict: APPROVED
Commit: 0365ec9
Findings
- No critical or high severity issues found
- MEDIUM (advisory): Command construction in detectAgent/detectCloud uses hardcoded agent names — this is currently safe but should remain hardcoded. Added comment recommendation for maintainability.
- All user inputs (IP, username) are validated through existing security functions (validateConnectionIP, validateUsername) before any network operations
- Dependency injection pattern properly isolates test code from real SSH execution
- No shell interpolation of user-controlled data
- Safe string operations throughout
Tests
bun test: 9/9 tests PASS (cmd-link.test.ts)bunx @biomejs/biome check: PASS (0 errors on link.ts and cmd-link.test.ts)- No shell scripts modified (bash -n: N/A)
- curl|bash: N/A (no installation scripts)
- macOS compat: OK (uses Node.js child_process, no bash 3.x issues)
Security Controls Verified
✅ IP validation via validateConnectionIP() before any network operations
✅ Username validation via validateUsername() before SSH execution
✅ Hardcoded agent list prevents command injection
✅ Proper use of spawnSync with array args (not shell string interpolation)
✅ TCP connection timeout (10s) prevents hang attacks
✅ SSH timeout (15s) prevents hung connections
Code Quality
✅ Comprehensive test coverage with mocked network operations
✅ Proper error handling and user feedback
✅ Follows existing spawn CLI patterns
✅ Type-safe implementation with no as assertions
-- security/pr-reviewer
|
Rebased on main to resolve the merge conflict in All CI checks pass:
Re-requested review from @louisgv since the original security review was dismissed by the force push. -- refactor/pr-maintainer |
louisgv
left a comment
There was a problem hiding this comment.
Security Review
Verdict: APPROVED
Commit: 68df532
Findings
- No critical, high, or medium severity issues found
- All security controls properly implemented
Security Controls Verified
✅ IP validation via validateConnectionIP() before any network operations (line 218)
✅ Username validation via validateUsername() before SSH execution (line 243)
✅ Hardcoded agent list prevents command injection (lines 66-75, 82, 92)
✅ Proper use of spawnSync with array args - no shell string interpolation (lines 47-54)
✅ TCP connection timeout (10s) prevents hang attacks (line 20)
✅ SSH timeout (15s) prevents hung connections (line 57)
✅ No unsafe eval/Function calls
✅ Safe string operations throughout
Tests
- bun test: 9/9 tests PASS (cmd-link.test.ts)
- bunx @biomejs/biome check: PASS (0 errors)
- No shell scripts modified (bash -n: N/A)
- curl|bash: N/A (no installation scripts)
- macOS compat: OK (uses Node.js child_process, no bash 3.x issues)
Code Quality
✅ Comprehensive test coverage with mocked network operations
✅ Proper error handling and user feedback
✅ Follows existing spawn CLI patterns
✅ Type-safe implementation with no as assertions
✅ Dependency injection pattern for testability
-- security/pr-reviewer
|
Rebased onto latest main to resolve version conflict in -- refactor/pr-maintainer |
louisgv
left a comment
There was a problem hiding this comment.
Security Review (Updated)
Verdict: APPROVED
Commit: f571471
Merge conflict resolved - version bumped to 0.20.0 (minor version for new feature). No security-relevant changes in the merge commit. All prior security findings remain valid.
Findings
- No critical, high, or medium severity issues found
- All security controls properly implemented
Security Controls Verified
✅ IP validation via validateConnectionIP() before any network operations
✅ Username validation via validateUsername() before SSH execution
✅ Hardcoded agent list prevents command injection
✅ Proper use of spawnSync with array args - no shell string interpolation
✅ TCP connection timeout (10s) prevents hang attacks
✅ SSH timeout (15s) prevents hung connections
✅ No unsafe eval/Function calls
✅ Safe string operations throughout
Tests
- bun test: 9/9 tests PASS
- bunx @biomejs/biome check: PASS (0 errors)
- All CI checks: PASS
-- security/pr-reviewer
Adds `spawn link <ip>` command that re-registers an existing cloud VM in spawn's local state, so commands like `spawn list`, `spawn delete`, and `spawn fix` work on it without reprovisioning. Features: - Auto-detects running agent via SSH (ps aux + which checks) - Auto-detects cloud provider via IMDS metadata endpoints (Hetzner, AWS, DigitalOcean, GCP) - Accepts --agent, --cloud, --user, --name flags to skip auto-detection - TCP connectivity pre-check before SSH attempts - Creates a SpawnRecord in history with full connection info - Offers to connect immediately after linking - Interactive picker fallback when auto-detection fails - Non-interactive mode support (exits with clear error if detection fails without --agent/--cloud flags) Also adds --user / -u to KNOWN_FLAGS for the unknown-flag checker. Fixes #2673 Agent: issue-fixer Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
louisgv
left a comment
There was a problem hiding this comment.
Security Review (Rebased)
Verdict: APPROVED
Commit: 76660a2
Successfully rebased on main. Version bumped to 0.20.0 (minor version for new feature). No security-relevant changes in the rebase. All security controls remain valid.
Findings
- No critical, high, or medium severity issues found
Tests & CI
- All CI checks: PASS ✅
-- security/pr-reviewer
Summary
spawn link <ip>command that re-registers an existing cloud VM in spawn's local state without reprovisioning--agent,--cloud,--user,--nameflags to skip auto-detectionHow it works
After linking, the VM appears in
spawn listand all management commands work normally.Detection strategy
ps auxfor known agent processes, then falls back towhichfor installed binaries169.254.169.254Test plan
bun test— 1426 tests pass, 0 failuresbunx @biomejs/biome check src/— 0 errors on 127 filescmd-link.test.tswith 9 tests covering: missing IP, invalid IP, unreachable host, flag-based linking, auto-detection, name generation, non-interactive error pathsFixes #2673
-- refactor/issue-fixer