mirror of
https://github.com/stablyai/orca.git
synced 2026-11-18 11:54:46 +00:00
* feat(cloud): SSH into Orca Cloud workspaces (orca ssh, ssh-proxy, VS Code/Cursor Remote-SSH) - VM: unprivileged key-only sshd on 127.0.0.1:2222 (orca-sshd), host key and Orca-managed authorized_keys on the persistent disk; orca-ssh-keys entry point; provision extracts only the server binaries (dnf or apt, +1.5-2 MB) and unlocks the sandbox user for key logins. - Control plane: POST/DELETE /v1/sandboxes/:id/ssh-keys runs the fixed entry point and answers the pinned host key; editor Remote-SSH server hosts on the egress allowlist. - Desktop: per-workspace ed25519 keys in userData (0600), Orca-owned ssh_config + pinned known_hosts, ~/.ssh/config Include only after consent; wake -> key -> runtime port forward (openRuntimePortForward reason 'ssh'); revoke (deferred while asleep); SSH traffic keeps the workspace awake. - CLI: orca ssh-proxy <workspace> (ProxyCommand) and orca ssh <workspace>. - UI: Open in -> VS Code / Cursor over Remote SSH, SSH submenu (Copy SSH Command, Revoke), include consent dialog, progress/error toasts. * fix(cloud-ssh): review fixes — no agent forwarding, reinstall per VM boot, wake to revoke - ForwardAgent/ForwardX11 no in Orca's host blocks; AllowAgentForwarding no in the VM's sshd. - Reinstall the key (idempotent; restarts sshd, re-pins the host key) once per VM boot, so a wiped disk, rollover or dead sshd heals on the next connection. - Revoke wakes the VM to remove its copy; only an unreachable VM falls back to the queue. - orca-ssh-keys rejects multi-line keys; sshd log truncated per start; audit log entries for ssh key add/remove; state parsed per entry; % escaped in ssh_config paths; ProxyCommand pinned to this app's profile; ssh-proxy flushes stdout before exit; --print shell-quotes; editors open via --folder-uri with a checked path; "Remove from ~/.ssh/config" + one-time backup.
81 lines
3.1 KiB
TypeScript
81 lines
3.1 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import { EDITOR_REMOTE_SERVER_HOSTS, compileNetworkPolicy, gitBasicAuthorization } from '../src/network-policy'
|
|
|
|
const deny = { response: { statusCode: 403, body: 'orca-egress-denied', contentType: 'text/plain' } }
|
|
|
|
describe('compileNetworkPolicy', () => {
|
|
it('fails closed: no wildcard, and credential hosts end with a deny rule', () => {
|
|
const policy = compileNetworkPolicy({
|
|
mode: 'allowlist',
|
|
allowlist: ['registry.npmjs.org', 'github.com'],
|
|
credentials: [
|
|
{
|
|
host: 'github.com',
|
|
header: 'Authorization',
|
|
placeholders: [gitBasicAuthorization('orca-ph-1')],
|
|
via: 'transform',
|
|
value: gitBasicAuthorization('ghs_real')
|
|
},
|
|
{
|
|
host: 'api.github.com',
|
|
header: 'authorization',
|
|
placeholders: ['Bearer orca-ph-1', 'token orca-ph-1'],
|
|
via: 'forward',
|
|
forwardURL: 'https://sandbox.onorca.dev/v1/egress/proxy'
|
|
}
|
|
]
|
|
})
|
|
expect(policy).toEqual({
|
|
allow: {
|
|
'registry.npmjs.org': [],
|
|
'github.com': [
|
|
{
|
|
match: { headers: [{ key: { exact: 'authorization' }, value: { exact: 'Basic eC1hY2Nlc3MtdG9rZW46b3JjYS1waC0x' } }] },
|
|
transform: [{ headers: { authorization: 'Basic eC1hY2Nlc3MtdG9rZW46Z2hzX3JlYWw=' } }]
|
|
},
|
|
deny
|
|
],
|
|
'api.github.com': [
|
|
{
|
|
match: { headers: [{ key: { exact: 'authorization' }, value: { exact: 'Bearer orca-ph-1' } }] },
|
|
forwardURL: 'https://sandbox.onorca.dev/v1/egress/proxy'
|
|
},
|
|
{
|
|
match: { headers: [{ key: { exact: 'authorization' }, value: { exact: 'token orca-ph-1' } }] },
|
|
forwardURL: 'https://sandbox.onorca.dev/v1/egress/proxy'
|
|
},
|
|
deny
|
|
]
|
|
}
|
|
})
|
|
})
|
|
|
|
it('allows github.com by default so public repos clone without a GitHub App install', () => {
|
|
expect(compileNetworkPolicy({ mode: 'allowlist' }).allow['github.com']).toEqual([])
|
|
})
|
|
|
|
it('adds the wildcard only when a workspace opts into open egress', () => {
|
|
expect(compileNetworkPolicy({ mode: 'open', allowlist: [] })).toEqual({ allow: { '*': [] } })
|
|
})
|
|
|
|
it('rejects malformed hosts and wildcard credential hosts', () => {
|
|
expect(() => compileNetworkPolicy({ mode: 'allowlist', allowlist: ['https://x.com'] })).toThrow()
|
|
expect(() =>
|
|
compileNetworkPolicy({
|
|
mode: 'allowlist',
|
|
allowlist: [],
|
|
credentials: [{ host: '*.github.com', header: 'authorization', placeholders: ['p'], via: 'transform', value: 'v' }]
|
|
})
|
|
).toThrow(/exact host/)
|
|
})
|
|
|
|
it('lets editors reach their Remote-SSH server downloads by default, still without a wildcard', () => {
|
|
const { allow } = compileNetworkPolicy({ mode: 'allowlist' })
|
|
for (const host of ['update.code.visualstudio.com', 'vscode.download.prss.microsoft.com', 'cursor.blob.core.windows.net']) {
|
|
expect(EDITOR_REMOTE_SERVER_HOSTS).toContain(host)
|
|
expect(allow[host]).toEqual([])
|
|
}
|
|
expect(allow['*']).toBeUndefined()
|
|
})
|
|
})
|