DeepSeek Harness Tauri 桌面版 | Only 8mb installer, zero environment setup, preset plugins, Windows / macOS / Linux.
fix(ssh): final-review fixes — exact-write save (cleared optional fields stay cleared), redact install failure, tar -- separator, openSession reconnect refusal, loopback guard aligned to capability
Menghuan191817963651b3e2
diff --git a/packages/dsh-tauri-ssh/src/host/apply.test.ts b/packages/dsh-tauri-ssh/src/host/apply.test.tsindex 229849be..bfac405e 100644--- a/packages/dsh-tauri-ssh/src/host/apply.test.ts+++ b/packages/dsh-tauri-ssh/src/host/apply.test.ts@@ -227,7 +227,7 @@ describe('ssh-remote plugin', () => {user: 'root',remotePort: 3080,}, { password: 'sekrit', passphrase: 'PHRASE' })- expect(settings.update).toHaveBeenCalledWith({+ expect(settings.replace).toHaveBeenCalledWith({machines: {a: {id: 'a',@@ -261,6 +261,34 @@ describe('ssh-remote plugin', () => {expect(views[0]).toMatchObject({ name: 'alpha-2', hasPassword: true })})+ it('clears optional appearance fields on save and keeps sibling machines intact', async () => {+ const settings = scriptedSettings()+ settings.set(String(MACHINES_NAMESPACE), {+ machines: {+ a: { ...machine('a'), color: '#ff0000', tintBorder: true, startCommand: 'custom dsh web' },+ b: machine('b'),+ },+ })+ const { service } = boot({ settings })+ await service.save('a' as never, {+ name: 'alpha-3',+ host: '10.0.0.1',+ port: 22,+ user: 'root',+ remotePort: 3080,+ })+ const viewA = service.profileViews().find(view => view.id === 'a')+ // 清除方向:color/tintBorder/startCommand 的空/关形态(row 缺位)必须真+ // 清除——save 走整节 replace 精确写;若退回 update 深合并,已存层会把+ // 这三个字段复活(回归守护)。+ expect(viewA).not.toHaveProperty('color')+ expect(viewA).not.toHaveProperty('tintBorder')+ expect(viewA).not.toHaveProperty('startCommand')+ expect(settings.update).not.toHaveBeenCalled()+ // 精确写重述全表:同表其他机器原样保留+ expect(service.profileViews().find(view => view.id === 'b')).toMatchObject({ name: 'machine-b', hasPassword: true })+ })+it('keeps stored secrets on save and stores the start command', async () => {const settings = scriptedSettings()settings.set(String(MACHINES_NAMESPACE), {diff --git a/packages/dsh-tauri-ssh/src/host/apply.ts b/packages/dsh-tauri-ssh/src/host/apply.tsindex 9d15d97a..d709d746 100644--- a/packages/dsh-tauri-ssh/src/host/apply.ts+++ b/packages/dsh-tauri-ssh/src/host/apply.ts@@ -220,8 +220,10 @@ export class SshRemoteService implements SshApiHost {/*** Upsert one machine profile: merge the config row and any freshly typed* secrets into the stored profile (secrets omitted keep the stored value).- * The scope write validates the whole section; the watch refreshes the- * manager automatically.+ * Optional fields absent from the row are *cleared* — the write restates+ * the full machine table through `replace` (exact), because `update`'s+ * deep merge would resurrect cleared fields from the stored layer. The+ * watch refreshes the manager automatically.* @param machineId - the profile id (the settings dict key).* @param row - the config fields as the settings page edited them.* @param secrets - write-only secret values; absent fields keep stored ones.@@ -255,7 +257,11 @@ export class SshRemoteService implements SshApiHost {if (secrets.passphrase !== undefined && secrets.passphrase !== '')next.passphrase = secrets.passphrase}- await this.scope.update({ machines: { [machineId]: next } })+ // 精确写:像 remove() 一样整节 replace 重述全量机器表。`update` 是深合+ // 并——被清除的可选字段(color/tintBorder/startCommand 的空/关形态在+ // next 中缺位)会从已存层复活,导致「清除」静默失效。+ machines.set(machineId, next)+ await this.scope.replace({ machines: Object.fromEntries(machines) })}/**diff --git a/packages/dsh-tauri-ssh/src/host/service/manager.ts b/packages/dsh-tauri-ssh/src/host/service/manager.tsindex cf1b2bb9..977757ab 100644--- a/packages/dsh-tauri-ssh/src/host/service/manager.ts+++ b/packages/dsh-tauri-ssh/src/host/service/manager.ts@@ -203,6 +203,10 @@ export class SshManager {*/async openSession(machineId: MachineId, signal?: AbortSignal): Promise<SshSession> {const profile = this.requireProfile(machineId)+ // 与 connect/install 一致:重连窗口拥有机器时拒绝新会话(S3 的在途操+ // 作一致性语义——sync 引擎经此开专用会话,裸 /api-ssh 调用方同样拿到+ // 可区分的 machine-reconnecting 而非并行建连)。+ this.refuseWhileReconnecting(machineId, this.ensureState(machineId))return await this.deps.transport.connect(profile, key => this.checkHostKey(machineId, key), signal)}@@ -534,7 +538,9 @@ export class SshManager {}// The locally captured message: a superseded attempt must not read// state.lastError back — that slot may already belong to a newer try.- const message = error instanceof Error ? error.message : String(error)+ // 与其它失败路径对称地过脱敏(纵深防御:安装错误源今天不含 secret,+ // 但不留给未来调用方)。+ const message = this.redacted(machineId, error instanceof Error ? error.message : String(error))// Exception failures (platform probe, planner rejects such as// REMOTE_PLATFORM_UNSUPPORTED, transport exec rejects including the// install timeout, the missing entry) never reach the script's owndiff --git a/packages/dsh-tauri-ssh/src/host/service/sync-local.ts b/packages/dsh-tauri-ssh/src/host/service/sync-local.tsindex 64ee5d24..860a4ea3 100644--- a/packages/dsh-tauri-ssh/src/host/service/sync-local.ts+++ b/packages/dsh-tauri-ssh/src/host/service/sync-local.ts@@ -107,7 +107,8 @@ function skillNamesOf(dir: string): string[] {*/export function tarPacker(): (dir: string, names: readonly string[]) => Promise<Buffer> {return async (dir, names) => {- const { stdout, stderr } = await execFileAsync('tar', ['-cf', '-', '-C', dir, ...names], {+ // `--` 分隔符:防止以 `-` 开头的 skill 目录名被 tar 当作选项。+ const { stdout, stderr } = await execFileAsync('tar', ['-cf', '-', '-C', dir, '--', ...names], {maxBuffer: MAX_TAR_BYTES,windowsHide: true,encoding: 'buffer',diff --git a/src-tauri/src/bridge/remote.rs b/src-tauri/src/bridge/remote.rsindex fa272c7a..2c544397 100644--- a/src-tauri/src/bridge/remote.rs+++ b/src-tauri/src/bridge/remote.rs@@ -28,8 +28,10 @@ fn sanitize_label_part(raw: &str) -> String {.collect()}-/// 校验隧道 URL:仅接受回环 host 的明文 http(隧道由引擎建在-/// `127.0.0.1:<port>`,见插件 `SshLink`;非回环/非 http 一律拒绝)。+/// 校验隧道 URL:仅接受 `127.0.0.1` host 的明文 http(隧道由引擎建在+/// `127.0.0.1:<port>`,见插件 `SshLink`;与 capability `remote.urls`+/// `http://127.0.0.1:*` 精确对齐——`localhost`/`[::1]` 过守卫却命不中+/// capability,弹窗会静默退化为无 IPC 的纯 web,故在命令侧一并拒绝)。fn validate_loopback_http_url(raw: &str) -> Result<tauri::Url, String> {let url: tauri::Url = raw.parse()@@ -40,13 +42,9 @@ fn validate_loopback_http_url(raw: &str) -> Result<tauri::Url, String> {url.scheme()));}- // url::Url 的 host_str 对 IPv6 保留方括号("[::1]"),比较前先剥掉。- let host = url.host_str().unwrap_or("");- let bare_host = host.trim_start_matches('[').trim_end_matches(']');- let is_loopback = matches!(bare_host, "127.0.0.1" | "::1" | "localhost");- if !is_loopback {+ if url.host_str() != Some("127.0.0.1") {return Err(format!(- "REMOTE_URL_INVALID: only loopback hosts are allowed, got {:?}",+ "REMOTE_URL_INVALID: only http://127.0.0.1:<port> tunnel URLs are allowed, got {:?}",url.host_str()));}@@ -121,8 +119,6 @@ mod tests {for raw in ["http://127.0.0.1:3080","http://127.0.0.1:49152/",- "http://localhost:3080",- "http://[::1]:3080",] {let url = validate_loopback_http_url(raw).unwrap_or_else(|err| panic!("{raw} should pass: {err}"));@@ -136,6 +132,8 @@ mod tests {"https://127.0.0.1:3080", // https 不允许(隧道是明文回环)"http://192.168.1.5:3080", // 非回环"http://example.com", // 公网域名+ "http://localhost:3080", // 命不中 capability remote.urls,命令侧一并拒绝+ "http://[::1]:3080", // 同上:与 127.0.0.1 精确对齐"file:///etc/passwd", // 非 http scheme"not a url", // 解析失败"", // 空