diff --git a/.agents/notes/implemented/feature/2026-11-21-remote-connections-window.md b/.agents/notes/implemented/feature/2026-11-21-remote-connections-window.md index 8910e2ec7..fef163d2a 100644 --- a/.agents/notes/implemented/feature/2026-11-21-remote-connections-window.md +++ b/.agents/notes/implemented/feature/2026-11-21-remote-connections-window.md @@ -4,7 +4,7 @@ ## 先说结论 -欢迎页的“远程开发”按钮(与新建项目、打开、克隆仓库并列,不收进菜单)和标题栏项目菜单里的“远程开发…”会打开一个窗口:左边是保存的 SSH 连接,右边是选中连接的表单、“测试连接”和测试到的主机信息。连接列表由 Rust Core 定义格式和规则(`remote.connections`、`remote.editConnections`),桌面端只负责读文件、把 Core 生成的整份文档原子写回。窗口里不保存任何秘密:密码、私钥口令和主机指纹确认都由 OpenSSH 在测试时经 AskPass(Lithe 自己充当 `SSH_ASKPASS` 程序,把问题转回主程序)提出,和 Git 认证共用同一个提问框,答完即丢。 +欢迎页的“远程开发”按钮(与新建项目、打开、克隆仓库并列,不收进菜单)和标题栏项目菜单里的“远程开发…”会打开一个窗口:左边是保存的 SSH 连接,右边是选中连接的表单、“测试连接”和测试到的主机信息。连接列表由 Rust Core 定义格式和规则(`remote.connections`、`remote.editConnections`),桌面端只负责读文件、把 Core 生成的整份文档原子写回。窗口里不保存任何秘密:密码、私钥口令和主机指纹确认都由 OpenSSH 在测试时经 AskPass(Lithe 自己充当 `SSH_ASKPASS` 程序,把问题转回主程序)提出,和 Git 认证共用同一个提问框。密码和私钥口令只有在用户勾选“记住”、而且这次真的登录成功后,才存进系统钥匙串或 Windows 凭据管理器;验证码和主机指纹确认从不记住。 ## 问题 @@ -12,7 +12,8 @@ Issue #2231 要求远程开发先能“告诉 Lithe 连哪台机器、怎么登 - 字段规则(主机不能带 `user@`、端口范围、名称去重、最多 128 项)放在哪里,换 UI 壳子时不用重写; - 保存时如果文件已被另一个窗口或手工改过,不能把别人的修改覆盖掉; -- 设计 S12 规定秘密只出现在 AskPass 的问题和答案里,S15 规定 Lithe 不读私钥内容。 +- 设计 S12 规定秘密只出现在 AskPass 的问题和答案里,用户勾选“记住”后才进系统钥匙串,验证码从不记住;S15 规定 Lithe 不读私钥内容。 +- 记住的密码一旦记错,每次连接都会自动发出去,可能让服务器锁定账号。 ## 决策 @@ -22,15 +23,28 @@ Issue #2231 要求远程开发先能“告诉 Lithe 连哪台机器、怎么登 - `desktop/internal/remoteconn` 只做两件事:按 Core 给出的相对路径和大小上限,从平台偏好目录读取 `remote/connections.json`;把 Core 编辑后返回的整份文档,以“读取时的字节”为前提原子写回(`configfile`)。文件在读取之后被改过,写入就失败(`ErrConflict`),窗口提示重新读取,不会覆盖。 - 每次点“保存”或确认“删除”都立即写一次,并且写完重新读取文件来显示,不维护一份和磁盘不同的工作副本。打开窗口只读不写,没有文件时不会创建。 -### 秘密不经过窗口 +### 秘密只经过 AskPass,不进连接列表 - 表单只有“认证方式”和私钥路径,没有密码框。私钥只保存路径,Lithe 不打开、不读取私钥文件,也不接受粘贴的私钥。 - “测试连接”调用 Core 的 `RemoteProbe`,Core 运行 PATH 里的 OpenSSH。OpenSSH 的每个问题(密码、口令、验证码、首次连接时的主机指纹确认)通过 AskPass 回到窗口,进入和 Git 认证相同的队列(`gitAuthState`),问题带 `Remote` 标记,只换标题、提示和回答用的 Core 方法(`RemoteAuthRespond`)。 - 取消提问、点“停止”或关闭窗口都会取消测试;被取消的测试不再追问,也不显示结果。 +### 勾选“记住”后才把密码和口令存进钥匙串 + +“记住”勾选框(`desktop/internal/workbench/remote_answers.go`,存取在 `desktop/internal/remoteconn/answers.go`)的规则: + +- **哪些连接能记住**:只有已保存的 SSH 连接。未保存的连接没有稳定的身份可以挂靠;WSL 和本机容器不走 SSH 密码。已保存主机上的容器(连接 id 为 `<已保存连接 id>/<容器身份>`)用这台主机记住的答案。 +- **哪些问题能记住**:密码和私钥口令。验证码每次都不同,主机指纹确认必须由人做,都不显示勾选框。 +- **按什么保存**:每个已保存连接在 `@host/remote-answers` 下一个条目(键是连接 id 的摘要),里面按“提问类型 + 主机、端口、用户、ProxyJump + 提问原文”的摘要区分,最多 8 条。同一个连接经跳板机时可能先后问两个不同的密码,所以不能只按提问类型保存。 +- **什么时候写入**:勾选后提交的答案先留在内存,等这次连接结束、Core 报告登录成功(`Connected`,或登录成功但远端没有对应服务端构建的 `UnsupportedPlatform`)才写入。登录失败不写,记错的密码不会被存下来。不勾选提交时,结束后删除已记住的答案,不论成败。 +- **什么时候自动填入**:只在 OpenSSH 这次第一次问这个问题(`Attempt` 为 1)时自动发出记住的答案。OpenSSH 再问同一个问题,说明主机拒绝了它:窗口改为显示提问框,标明“主机没有接受记住的回答”,勾选框保持勾选,结束时删除被拒的答案。自动发出后 Core 报告认证失败(且不是用户取消)也删除。这样记错的密码最多发一次。 +- **后台自动重连**:只发送记住的答案,其余问题直接取消,不在后台弹提问框。 +- **清除**:连接详情“更多”菜单里的“清除记住的密码”;删除连接时也一并清除。 +- **还没做到的**:Go 侧的答案仍以 `string` 经过 Viva 输入框、`core.Client` 和 `credentials.Store`,不能按 S14 用完清零;删除连接时,保留会话的令牌(`@host/remote-sessions`)没有清理。两者都需要单独设计,见 #2332。 + ### 日志只记动作 -窗口只记录 `remote.connections.open`、`remote.connection.new/select/save/remove/test/test.stop` 和 `remote.authentication.answer/retry/cancel` 等动作,以及 Core 的固定状态或错误码。主机、用户名、私钥路径、OpenSSH 输出、提问原文和答案都不进日志,`remote_test.go` 用 `loggedAny` 检查。 +窗口只记录 `remote.connections.open`、`remote.connection.new/select/save/remove/test/test.stop/forgetAnswers` 和 `remote.authentication.answer/retry/cancel` 等动作,以及 Core 的固定状态或错误码。主机、用户名、私钥路径、OpenSSH 输出、提问原文和答案都不进日志,`remote_test.go` 用 `loggedAny` 检查。 ### 列表选中行跟着表单走 @@ -39,26 +53,29 @@ Viva 的 `ListState.Select` 只能选到列表上一帧已经声明过的行。 ## 考虑过的备选方案 - **桌面端自己校验字段、自己定义 JSON 格式**:Go 里写一遍,将来换 UI 壳子还要再写一遍,和“通用逻辑进 Rust Core”的约定冲突。没有采用。 -- **沿用旧客户端的“记住到钥匙串”**:用户少输一次密码,但秘密会离开 AskPass 的问答,违反 S12;而且记错的密码会被重复发送。没有采用。 +- **沿用旧客户端的“记住到钥匙串”(提交就写入,每次提问都自动发送)**:记错的密码会被存下来并反复发送,可能让服务器锁定账号;未保存的连接也会在钥匙串里留下条目。没有采用。最初的做法是完全不记住、答完即丢,但用户每次连接都要重新输入密码;现在改为上面的规则:只在勾选且登录成功后写入,只在第一次提问时自动填入,被拒绝就删除。 +- **提交时立即写入,失败再删**:进程在两步之间退出时,记错的密码就留下了。改为登录成功后才写入。 - **把整张列表当工作副本编辑,关窗口时统一保存**:可以批量修改,但关窗口时要么丢修改,要么要再问一次;和“保存后重新读取显示真实来源”的设置规则也不一致。没有采用。 - **为远程连接单独做一个认证弹窗**:两个弹窗可能同时出现、互相遮挡。共用 Git 的队列后,同一时间只显示一个问题,按提出顺序逐个回答。 ## 后果 -- 收益:字段规则只有 Core 一份;Windows 和 macOS 用同一份 Go 代码;秘密只在 OpenSSH 和 AskPass 之间流动;并发修改不会互相覆盖。 -- 代价:每次保存都是一次完整的读、改、写和重新读取;Core 没有返回字段的错误只能显示在窗口底部。 +- 收益:字段规则只有 Core 一份;Windows 和 macOS 用同一份 Go 代码;秘密只在 OpenSSH、AskPass 和(用户勾选后的)系统钥匙串之间流动;并发修改不会互相覆盖。 +- 代价:每次保存都是一次完整的读、改、写和重新读取;Core 没有返回字段的错误只能显示在窗口底部;记住的答案在内存里仍是 `string`(#2332)。 - Windows 上 OpenSSH 能否通过 GUI 子系统的 `lithe` 助手读到答案仍待实机验证;打开远程项目、文件夹选择和远端服务部署在后续阶段实现。 ## 验证 - `desktop/internal/remoteconn/remoteconn_test.go`:读取不创建文件、冲突时不写入、损坏文件报 `ErrDamaged`。 -- `desktop/internal/workbench/remote_test.go`:保存、改名、删除前确认;字段被拒绝时显示在字段下且不写文件;新保存的连接是列表选中行;测试时在窗口中回答密码并显示主机信息;停止和关窗口都会取消测试且不再追问;日志不含主机和用户名。 +- `desktop/internal/workbench/remote_test.go`:保存、改名、删除前确认;字段被拒绝时显示在字段下且不写文件;新保存的连接是列表选中行;测试时在窗口中回答密码并显示主机信息,未保存的连接不显示“记住”;停止和关窗口都会取消测试且不再追问;日志不含主机和用户名。 +- `desktop/internal/remoteconn/answers_test.go`:只有密码和口令能记住;答案按登录身份和提问原文区分;替换、清除和不变时不写入;超过 8 条或超出系统凭据存储的大小上限时只留最新的;解不开的条目当作没有记住。 +- `desktop/internal/workbench/remote_answers_test.go`:用一个按脚本回答的假 `ssh` 走完“勾选但密码错不写入 → 登录成功才写入 → 第一次自动填入 → 被拒后改问并替换 → 取消勾选后删除”;“更多”菜单清除和删除连接时清除;后台重连只发记住的答案、第二次提问和验证码都被取消;按登录结果决定写入或删除的九种组合。 - `desktop/internal/workbench/remote_connections_visual_test.go` 生成 `docs/assets/remote-connections/` 下的截图。 ```bash -scripts/desktop/desktop-go.sh test ./internal/remoteconn ./internal/workbench -run 'Remote|GitAuth' -count=1 +scripts/desktop/desktop-go.sh test ./internal/remoteconn ./internal/workbench -run 'Remote|GitAuth|Answer|Rememberable' -count=1 ``` ## 适用范围 -`desktop/internal/remoteconn/`、`desktop/internal/workbench/remote.go`、`desktop/internal/workbench/remote_view.go`,以及 `desktop/internal/workbench/git_auth.go` 中带 `Remote` 标记的提问。后续“打开远程工作区”“记住最近文件夹”都要通过同一个 `remoteconn` 和 Core 的 `remote.editConnections`,不要另存一份连接信息。 +`desktop/internal/remoteconn/`、`desktop/internal/workbench/remote.go`、`desktop/internal/workbench/remote_view.go`、`desktop/internal/workbench/remote_answers.go`,以及 `desktop/internal/workbench/git_auth.go` 中带 `Remote` 标记的提问。后续“打开远程工作区”“记住最近文件夹”都要通过同一个 `remoteconn` 和 Core 的 `remote.editConnections`,不要另存一份连接信息。 diff --git a/.github/workflows/desktop-autobuild.yml b/.github/workflows/desktop-autobuild.yml index a4549332b..c62ec93ab 100644 --- a/.github/workflows/desktop-autobuild.yml +++ b/.github/workflows/desktop-autobuild.yml @@ -88,8 +88,9 @@ jobs: printf 'skip=%s\n' "$skip" } >> "$GITHUB_OUTPUT" - # The remote workspace server of the pinned source is built and smoke tested once, on both - # architectures; every package of this AutoBuild embeds those bytes. + # The remote workspace server of the pinned source is built once for linux amd64 and arm64 and + # tested on a runner of each architecture before any app is built; every package of this + # AutoBuild embeds those bytes. remote-server: name: Remote server needs: prepare diff --git a/.github/workflows/desktop-ci.yml b/.github/workflows/desktop-ci.yml index aa031625a..59a1cb781 100644 --- a/.github/workflows/desktop-ci.yml +++ b/.github/workflows/desktop-ci.yml @@ -281,8 +281,9 @@ jobs: if-no-files-found: warn retention-days: 14 - # Builds, checks and smoke tests the remote workspace server on both architectures. Desktop - # Release and Desktop AutoBuild call the same workflow and embed the artifact it uploads. + # Builds the remote workspace server for linux amd64 and arm64 in one job, then smoke tests + # each on a runner of its own architecture. Desktop Release and Desktop AutoBuild call the same + # workflow and embed the artifact it uploads. remote-server: name: Remote server uses: ./.github/workflows/desktop-remote-server.yml diff --git a/.github/workflows/desktop-release.yml b/.github/workflows/desktop-release.yml index 72544b113..6d4f67308 100644 --- a/.github/workflows/desktop-release.yml +++ b/.github/workflows/desktop-release.yml @@ -64,14 +64,16 @@ jobs: id: time run: printf 'timestamp=%s\n' "$(date -u '+%Y-%m-%dT%H:%M:%SZ')" >> "$GITHUB_OUTPUT" - # The remote workspace server is built and smoke tested once, on both architectures; every - # package of this release embeds those bytes. + # A release runs in three stages. First the remote workspace server is built once for linux + # amd64 and arm64 and tested on a runner of each architecture. remote-server: name: Remote server if: ${{ !inputs.feed_only }} needs: prepare uses: ./.github/workflows/desktop-remote-server.yml + # Then every platform builds the app with those server bytes embedded and packages it: the + # server is compiled into the app, so these cannot start before the first stage ends. build: name: Package ${{ matrix.os }} ${{ matrix.arch }} if: ${{ !inputs.feed_only }} @@ -215,6 +217,7 @@ jobs: if-no-files-found: error + # Last, the packages of every platform are checked together and published as one release. publish: name: Publish the release if: ${{ (github.event_name != 'workflow_dispatch' || inputs.publish) && !inputs.feed_only }} diff --git a/.github/workflows/desktop-remote-server.yml b/.github/workflows/desktop-remote-server.yml index 684260038..cb8d73f94 100644 --- a/.github/workflows/desktop-remote-server.yml +++ b/.github/workflows/desktop-remote-server.yml @@ -1,11 +1,13 @@ name: Desktop remote server -# Builds the remote workspace server for its Linux targets once, checks every executable, smoke -# tests each one on a runner of its own architecture and uploads them as the artifact -# remote-server-linux-musl (#2231). Desktop CI calls it to check a change; Desktop Release and -# Desktop AutoBuild call it, and every package job downloads that artifact and embeds those exact -# bytes (scripts/desktop/package-desktop.sh with LITHE_REMOTE_SERVER_STAGE), so all packages of a -# run carry the same server builds that were tested here. +# The first stage of every desktop run that ships the remote workspace server (#2231): one job +# builds the server for all of its Linux targets and checks every executable without running +# it, then one job per target downloads those bytes and smoke tests them on a runner of the +# target's own architecture, never under an emulator. The artifact is remote-server-linux-musl. +# Desktop CI calls this to check a change; Desktop Release and Desktop AutoBuild call it before +# building the app, and every package job downloads the artifact and embeds those exact bytes +# (scripts/desktop/package-desktop.sh with LITHE_REMOTE_SERVER_STAGE), so all packages of a run +# carry the same server builds that were tested here. on: workflow_call: inputs: @@ -20,7 +22,7 @@ permissions: jobs: build: - name: Remote server artifacts + name: Build for linux amd64 and arm64 runs-on: ubuntu-latest timeout-minutes: 20 @@ -51,13 +53,12 @@ jobs: - name: Build the remote server run: ./scripts/desktop/build-remote-server.sh - # Every executable is checked here; only the x86_64 one runs on this runner, and the arm64 - # job runs the aarch64 one on arm64 hardware. Sizes go to the job summary and never fail the - # lane (#2231, D9). - - name: Verify the remote server artifacts - run: node scripts/desktop/verify/verify-remote-server-artifacts.mjs --require-smoke x86_64-unknown-linux-musl --require-pinned + # The manifest, hashes, ELF machine and static linking of every executable. The test jobs + # run them. Sizes go to the job summary and never fail the lane (#2231, D9). + - name: Check the remote server executables + run: node scripts/desktop/verify/verify-remote-server-artifacts.mjs --smoke none --require-pinned - - name: Upload the remote server artifacts + - name: Upload the remote server builds uses: actions/upload-artifact@v7 with: name: remote-server-linux-musl @@ -65,11 +66,21 @@ jobs: if-no-files-found: error retention-days: 14 - arm64: - name: Remote server on arm64 + test: + name: Test on linux ${{ matrix.arch }} needs: build - runs-on: ubuntu-24.04-arm + runs-on: ${{ matrix.runner }} timeout-minutes: 10 + strategy: + fail-fast: false + matrix: + include: + - arch: amd64 + runner: ubuntu-24.04 + target: x86_64-unknown-linux-musl + - arch: arm64 + runner: ubuntu-24.04-arm + target: aarch64-unknown-linux-musl steps: - name: Check out source @@ -82,16 +93,18 @@ jobs: node-version: 20 # The same bytes that the build job built and uploaded, not a second build. - - name: Download the remote server artifacts + - name: Download the remote server builds uses: actions/download-artifact@v8 with: name: remote-server-linux-musl path: .artifacts/desktop/remote-server/ # Artifacts do not keep file modes. The SHA-256 check below still proves that these are - # the executables the build job verified. + # the executables the build job checked. - name: Restore the executable mode run: chmod 0755 .artifacts/desktop/remote-server/*/lithe-remote-server - - name: Smoke test the aarch64 server natively - run: node scripts/desktop/verify/verify-remote-server-artifacts.mjs --require-smoke aarch64-unknown-linux-musl --require-pinned + - name: Smoke test the ${{ matrix.target }} server natively + run: node scripts/desktop/verify/verify-remote-server-artifacts.mjs --smoke "$TARGET" --require-pinned + env: + TARGET: ${{ matrix.target }} diff --git a/desktop/internal/core/gitauth.go b/desktop/internal/core/gitauth.go index 41dfbc020..008a4083c 100644 --- a/desktop/internal/core/gitauth.go +++ b/desktop/internal/core/gitauth.go @@ -24,7 +24,8 @@ type GitAuthChallenge struct { // shown as it is. A Retry challenge carries Core's English wording, which the host replaces // with its own translated question. Prompt string - // Secret says the answer must not be shown or kept. + // Secret says the answer must not be shown or logged, nor kept unless the user ticks Remember + // under a remote connection's password or passphrase (workbench, remote_answers.go). Secret bool // Retry is the question whether to retry the transfer; only GitRetryAnswer accepts it. Retry bool diff --git a/desktop/internal/i18n/shared.generated.go b/desktop/internal/i18n/shared.generated.go index a25b9beed..df31d6145 100644 --- a/desktop/internal/i18n/shared.generated.go +++ b/desktop/internal/i18n/shared.generated.go @@ -1619,12 +1619,13 @@ var sharedCatalogs = map[string]map[string]string{ "desktop.refs.trackingStopped": "{branch} no longer tracks a remote branch", "desktop.remote.advanced": "Advanced", "desktop.remote.advancedSummary": "Connect timeout {timeout} · Keep-alive {keepAlive}", + "desktop.remote.answersForgotten": "Forgot the passwords and passphrases remembered for “{name}”.", "desktop.remote.auth.agent": "SSH agent", "desktop.remote.auth.auto": "Auto", "desktop.remote.auth.password": "Password", "desktop.remote.auth.privateKey": "Private key file", "desktop.remote.authentication": "Authentication", - "desktop.remote.authenticationHelp": "Auto: as your SSH config and ssh-agent decide. SSH agent: only keys held by ssh-agent. Private key: only the key file you choose; its passphrase is asked when connecting. Password: asked when connecting. Lithe never saves an answer.", + "desktop.remote.authenticationHelp": "Auto: as your SSH config and ssh-agent decide. SSH agent: only keys held by ssh-agent. Private key: only the key file you choose; its passphrase is asked when connecting. Password: asked when connecting. Lithe keeps an answer only when you tick Remember, in the system's credential store.", "desktop.remote.auto": "Automatic ({value})", "desktop.remote.browse.anchorUnusable": "Cannot prepare the local folder that stands for remote workspaces: {path}", "desktop.remote.browse.back": "Choose Later", @@ -1779,6 +1780,7 @@ var sharedCatalogs = map[string]map[string]string{ "desktop.remote.error.timeoutInvalid": "Enter 1 to 600 seconds.", "desktop.remote.error.unknown": "This connection no longer exists.", "desktop.remote.error.userInvalid": "This user name has characters SSH does not accept.", + "desktop.remote.forgetAnswers": "Forget Remembered Passwords", "desktop.remote.group": "Group", "desktop.remote.group.new": "New Group…", "desktop.remote.group.none": "No Group", @@ -2079,7 +2081,7 @@ var sharedCatalogs = map[string]map[string]string{ "desktop.remote.steps.title": "Connecting to {name}", "desktop.remote.steps.upload": "{sent} of {total}", "desktop.remote.stop": "Stop", - "desktop.remote.storageHelp": "Kept on this computer in {path}. Passwords and the contents of private keys are never saved.", + "desktop.remote.storageHelp": "Kept on this computer in {path}. The list holds no password and no private key contents; a password you choose to remember is kept in the system's credential store.", "desktop.remote.terminal.dropOutside": "Only files of this remote workspace can be dropped on its terminal. Files of this computer are not on the host.", "desktop.remote.terminal.notConnected": "the workspace is not connected to the host. Wait for it to connect again, or click Reconnect in the status bar.", "desktop.remote.terminal.tabNumber": "{name} ({number})", @@ -2131,6 +2133,11 @@ var sharedCatalogs = map[string]map[string]string{ "desktop.remote.wsl.userTooLong": "A Linux user name has at most 32 characters.", "desktop.remoteAuth.failed": "Cannot pass the answer to SSH: {reason}", "desktop.remoteAuth.refused": "SSH did not take the answer: it may be at most 8192 bytes and may not contain a line break. The question was cancelled.", + "desktop.remoteAuth.rememberFailed": "Cannot update the remembered passwords: {reason}", + "desktop.remoteAuth.rememberHint": "Saved in the system's credential store once the connection succeeds. Lithe fills it in only the first time the host asks; if the host refuses it, Lithe asks you.", + "desktop.remoteAuth.rememberPassphrase": "Remember passphrase", + "desktop.remoteAuth.rememberPassword": "Remember password", + "desktop.remoteAuth.rememberedRefused": "The host refused the remembered answer. Type it again.", "desktop.remoteAuth.secretHint": "The answer goes only to this SSH connection. Lithe does not keep it.", "desktop.remoteAuth.title": "SSH Authentication", "desktop.remoteSettings.chooseProgram": "Choose…", @@ -5596,12 +5603,13 @@ var sharedCatalogs = map[string]map[string]string{ "desktop.refs.trackingStopped": "{branch} 不再跟踪远程分支", "desktop.remote.advanced": "高级", "desktop.remote.advancedSummary": "连接超时 {timeout} · 保活间隔 {keepAlive}", + "desktop.remote.answersForgotten": "已清除“{name}”记住的密码和口令。", "desktop.remote.auth.agent": "SSH Agent", "desktop.remote.auth.auto": "自动", "desktop.remote.auth.password": "密码", "desktop.remote.auth.privateKey": "私钥文件", "desktop.remote.authentication": "身份验证", - "desktop.remote.authenticationHelp": "自动:按 SSH 配置和 ssh-agent 决定。SSH Agent:只用 ssh-agent 里的密钥。私钥文件:只用选定的私钥,口令在连接时询问。密码:在连接时询问。Lithe 不保存任何回答。", + "desktop.remote.authenticationHelp": "自动:按 SSH 配置和 ssh-agent 决定。SSH Agent:只用 ssh-agent 里的密钥。私钥文件:只用选定的私钥,口令在连接时询问。密码:在连接时询问。只有勾选“记住”的回答才会保存,保存在系统的凭据存储里。", "desktop.remote.auto": "自动({value})", "desktop.remote.browse.anchorUnusable": "无法准备代表远程工作区的本地文件夹:{path}", "desktop.remote.browse.back": "稍后再选", @@ -5756,6 +5764,7 @@ var sharedCatalogs = map[string]map[string]string{ "desktop.remote.error.timeoutInvalid": "请填 1 到 600 秒。", "desktop.remote.error.unknown": "这个连接已不存在。", "desktop.remote.error.userInvalid": "用户名含有 SSH 不接受的字符。", + "desktop.remote.forgetAnswers": "清除记住的密码", "desktop.remote.group": "分组", "desktop.remote.group.new": "新建分组…", "desktop.remote.group.none": "不分组", @@ -6056,7 +6065,7 @@ var sharedCatalogs = map[string]map[string]string{ "desktop.remote.steps.title": "正在连接 {name}", "desktop.remote.steps.upload": "{sent} / {total}", "desktop.remote.stop": "停止", - "desktop.remote.storageHelp": "保存在本机的 {path}。不会保存密码和私钥内容。", + "desktop.remote.storageHelp": "保存在本机的 {path}。列表里没有密码和私钥内容;勾选记住的密码保存在系统的凭据存储里。", "desktop.remote.terminal.dropOutside": "只能把这个远程工作区里的文件拖到它的终端,本机的文件不在主机上。", "desktop.remote.terminal.notConnected": "工作区未连接到主机。请等待重新连接,或点击状态栏中的“重新连接”。", "desktop.remote.terminal.tabNumber": "{name} ({number})", @@ -6108,6 +6117,11 @@ var sharedCatalogs = map[string]map[string]string{ "desktop.remote.wsl.userTooLong": "Linux 用户名最多 32 个字符。", "desktop.remoteAuth.failed": "无法把回答交给 SSH:{reason}", "desktop.remoteAuth.refused": "SSH 没有接受这个回答:回答最多 8192 字节,且不能包含换行。这个问题已取消。", + "desktop.remoteAuth.rememberFailed": "无法更新记住的密码:{reason}", + "desktop.remoteAuth.rememberHint": "连接成功后保存在系统的凭据存储里。之后只在主机第一次询问时自动填入;主机不接受时会改为询问你。", + "desktop.remoteAuth.rememberPassphrase": "记住口令", + "desktop.remoteAuth.rememberPassword": "记住密码", + "desktop.remoteAuth.rememberedRefused": "主机没有接受记住的回答,请重新输入。", "desktop.remoteAuth.secretHint": "回答只交给这次 SSH 连接,Lithe 不会保存。", "desktop.remoteAuth.title": "SSH 身份验证", "desktop.remoteSettings.chooseProgram": "选择…", diff --git a/desktop/internal/remoteconn/answers.go b/desktop/internal/remoteconn/answers.go new file mode 100644 index 000000000..89e310905 --- /dev/null +++ b/desktop/internal/remoteconn/answers.go @@ -0,0 +1,163 @@ +package remoteconn + +import ( + "context" + "crypto/sha256" + "encoding/hex" + "encoding/json" + "errors" + "slices" + "strconv" + "strings" + "sync" + + "github.com/1lck/Lithe-IDEA/desktop/internal/core" + "github.com/1lck/Lithe-IDEA/desktop/internal/credentials" +) + +// A password or key passphrase OpenSSH asks a saved connection for is remembered only when the +// user ticks Remember under the question (#2231, S12), and only in the platform secret store: +// never in a preference file, Core's state or the log. One-time codes, host keys and any other +// question are never remembered. +// +// Each saved connection has one item. Its account is a digest of the connection's id, so the +// store's list of items names no host. Its secret is a JSON list of the remembered answers, +// newest last, each filed under a digest of its question: the kind, the host, port, user and jump +// host the question was asked for, and OpenSSH's wording. An answer is therefore offered only to +// the same question of the same login, never to the host a connection was edited to before it is +// saved. answersLimit caps the list so the item fits Windows Credential Manager's 2560 bytes; a +// list the store still cannot hold keeps only its newest answer. + +// AnswersNamespace is the secret-store namespace of the remembered answers. +const AnswersNamespace = "@host/remote-answers" + +// answersLimit is how many answers one saved connection remembers. +const answersLimit = 8 + +// answerEntry is one remembered answer. +type answerEntry struct { + Question string `json:"question"` + Answer string `json:"answer"` +} + +// answersLock makes each change of a connection's list one read and one write, so two windows +// connecting at once do not drop each other's answer. +var answersLock sync.Mutex + +// Rememberable reports whether the answer to a question of kind may be remembered: a password or +// a key's passphrase. +func Rememberable(kind core.RemoteQuestionKind) bool { + return kind == core.RemoteQuestionPassword || kind == core.RemoteQuestionPassphrase +} + +// AnswerQuestion is the digest an answer to OpenSSH's question prompt, of kind, asked while +// logging in as login, is filed under: the first 128 bits of the SHA-256 of the fields, each +// ended by a NUL, which no field holds. +func AnswerQuestion(kind core.RemoteQuestionKind, login core.SSHConnection, prompt string) string { + digest := sha256.New() + for _, field := range []string{string(kind), login.Host, strconv.Itoa(int(login.Port)), login.User, login.ProxyJump, strings.TrimSpace(prompt)} { + digest.Write([]byte(field)) + digest.Write([]byte{0}) + } + return hex.EncodeToString(digest.Sum(nil)[:16]) +} + +// answersAccount is the store's key of connectionID's item: "answers." and the first 128 bits of +// the id's SHA-256, which the store's key alphabet allows. +func answersAccount(connectionID string) string { + sum := sha256.Sum256([]byte(connectionID)) + return "answers." + hex.EncodeToString(sum[:16]) +} + +// readAnswers is connectionID's list, oldest first. A secret that does not decode holds no answer +// that can be sent, so it reads as an empty list, which the next change replaces. +func readAnswers(ctx context.Context, secrets Secrets, connectionID string) ([]answerEntry, error) { + secret, found, err := secrets.Get(ctx, AnswersNamespace, answersAccount(connectionID)) + if err != nil || !found { + return nil, err + } + var answers []answerEntry + if json.Unmarshal([]byte(secret), &answers) != nil { + return nil, nil + } + return slices.DeleteFunc(answers, func(entry answerEntry) bool { return entry.Question == "" || entry.Answer == "" }), nil +} + +// writeAnswers stores answers as connectionID's list, removing the item when it is empty. A list +// too large for the store keeps only its newest answer. +func writeAnswers(ctx context.Context, secrets Secrets, connectionID string, answers []answerEntry) error { + account := answersAccount(connectionID) + if len(answers) == 0 { + return secrets.Delete(ctx, AnswersNamespace, account) + } + secret, err := json.Marshal(answers) + if err != nil { + return err + } + err = secrets.Set(ctx, AnswersNamespace, account, string(secret)) + if errors.Is(err, credentials.ErrTooLarge) && len(answers) > 1 { + return writeAnswers(ctx, secrets, connectionID, answers[len(answers)-1:]) + } + return err +} + +// RememberedAnswer is the answer connectionID remembers for question, an AnswerQuestion digest; +// found is false when it remembers none. +func RememberedAnswer(ctx context.Context, secrets Secrets, connectionID, question string) (answer string, found bool, err error) { + answersLock.Lock() + defer answersLock.Unlock() + answers, err := readAnswers(ctx, secrets, connectionID) + if err != nil { + return "", false, err + } + for _, entry := range answers { + if entry.Question == question { + return entry.Answer, true, nil + } + } + return "", false, nil +} + +// AnswerChange remembers Answer for Question, an AnswerQuestion digest, or, with Forget set, +// forgets the answer remembered for it. +type AnswerChange struct { + Question string + Answer string + Forget bool +} + +// ChangeAnswers applies changes to connectionID's list in order, in one write: a remembered answer +// replaces the question's earlier one and becomes the newest, and the oldest beyond answersLimit +// are forgotten. Changes that leave the list as it was write nothing. +func ChangeAnswers(ctx context.Context, secrets Secrets, connectionID string, changes []AnswerChange) error { + if len(changes) == 0 { + return nil + } + answersLock.Lock() + defer answersLock.Unlock() + answers, err := readAnswers(ctx, secrets, connectionID) + if err != nil { + return err + } + changed := slices.Clone(answers) + for _, change := range changes { + changed = slices.DeleteFunc(changed, func(entry answerEntry) bool { return entry.Question == change.Question }) + if !change.Forget && change.Answer != "" { + changed = append(changed, answerEntry{Question: change.Question, Answer: change.Answer}) + } + } + if len(changed) > answersLimit { + changed = changed[len(changed)-answersLimit:] + } + if slices.Equal(changed, answers) { + return nil + } + return writeAnswers(ctx, secrets, connectionID, changed) +} + +// ForgetAnswers forgets every answer connectionID remembers; forgetting none succeeds. +func ForgetAnswers(ctx context.Context, secrets Secrets, connectionID string) error { + answersLock.Lock() + defer answersLock.Unlock() + return secrets.Delete(ctx, AnswersNamespace, answersAccount(connectionID)) +} diff --git a/desktop/internal/remoteconn/answers_test.go b/desktop/internal/remoteconn/answers_test.go new file mode 100644 index 000000000..04301ef95 --- /dev/null +++ b/desktop/internal/remoteconn/answers_test.go @@ -0,0 +1,192 @@ +package remoteconn + +import ( + "context" + "fmt" + "regexp" + "strings" + "testing" + + "github.com/1lck/Lithe-IDEA/desktop/internal/core" + "github.com/1lck/Lithe-IDEA/desktop/internal/credentials" +) + +// cappedStore is a keptStore that refuses a secret longer than limit as the Windows store does. +type cappedStore struct { + keptStore + limit int +} + +func (s cappedStore) Set(ctx context.Context, namespace, key, secret string) error { + if len(secret) > s.limit { + return credentials.ErrTooLarge + } + return s.keptStore.Set(ctx, namespace, key, secret) +} + +var devbox = core.SSHConnection{Host: "devbox", Port: 2222, User: "dev"} + +// Only a password or a passphrase is remembered; a code, a host key or another question never. +func TestOnlyPasswordsAndPassphrasesAreRememberable(t *testing.T) { + for kind, want := range map[core.RemoteQuestionKind]bool{ + core.RemoteQuestionPassword: true, core.RemoteQuestionPassphrase: true, + core.RemoteQuestionCode: false, core.RemoteQuestionHostKey: false, core.RemoteQuestionOther: false, "": false, + } { + if got := Rememberable(kind); got != want { + t.Errorf("Rememberable(%q) = %v, want %v", kind, got, want) + } + } +} + +// A question's digest changes with its kind, its wording and every field of the login, so an +// answer is never offered to another host, port, user or jump host, and names none of them. +func TestAnswerQuestionNamesOneQuestionOfOneLogin(t *testing.T) { + question := AnswerQuestion(core.RemoteQuestionPassword, devbox, "dev@devbox's password: ") + if got := AnswerQuestion(core.RemoteQuestionPassword, devbox, " dev@devbox's password:"); got != question { + t.Fatal("the digest depends on the space around the wording") + } + if !regexp.MustCompile(`^[0-9a-f]{32}$`).MatchString(question) || strings.Contains(question, "devbox") { + t.Fatalf("digest %q", question) + } + jump := devbox + jump.ProxyJump = "bastion" + others := map[string]string{ + "kind": AnswerQuestion(core.RemoteQuestionPassphrase, devbox, "dev@devbox's password: "), + "prompt": AnswerQuestion(core.RemoteQuestionPassword, devbox, "Password: "), + "host": AnswerQuestion(core.RemoteQuestionPassword, core.SSHConnection{Host: "other", Port: 2222, User: "dev"}, "dev@devbox's password: "), + "port": AnswerQuestion(core.RemoteQuestionPassword, core.SSHConnection{Host: "devbox", Port: 22, User: "dev"}, "dev@devbox's password: "), + "user": AnswerQuestion(core.RemoteQuestionPassword, core.SSHConnection{Host: "devbox", Port: 2222, User: "root"}, "dev@devbox's password: "), + "jump": AnswerQuestion(core.RemoteQuestionPassword, jump, "dev@devbox's password: "), + } + for field, other := range others { + if other == question { + t.Errorf("changing the %s keeps the digest", field) + } + } +} + +// A remembered answer is found for its question only; remembering the question again replaces +// it; forgetting removes it and the item once the list is empty. Each connection has its own +// item, under an account that names no connection, and its secret names no host. +func TestRememberedAnswersReplaceAndForget(t *testing.T) { + ctx, store := testContext(t), keptStore{} + password := AnswerQuestion(core.RemoteQuestionPassword, devbox, "Password: ") + passphrase := AnswerQuestion(core.RemoteQuestionPassphrase, devbox, "Enter passphrase for key 'id': ") + if _, found, err := RememberedAnswer(ctx, store, "build", password); err != nil || found { + t.Fatalf("a connection that remembers nothing found an answer, %v", err) + } + if err := ChangeAnswers(ctx, store, "build", []AnswerChange{ + {Question: password, Answer: "first"}, {Question: passphrase, Answer: "phrase"}, {Question: password, Answer: "s3cret"}, + }); err != nil { + t.Fatal(err) + } + if err := ChangeAnswers(ctx, store, "other", []AnswerChange{{Question: password, Answer: "elsewhere"}}); err != nil { + t.Fatal(err) + } + if answer, found, _ := RememberedAnswer(ctx, store, "build", password); !found || answer != "s3cret" { + t.Fatalf("answer %q, %v; want the one remembered last", answer, found) + } + if answer, _, _ := RememberedAnswer(ctx, store, "other", password); answer != "elsewhere" { + t.Fatalf("the other connection's answer is %q", answer) + } + if len(store) != 2 { + t.Fatalf("the store holds %d items, want one per connection", len(store)) + } + account := regexp.MustCompile(`^` + regexp.QuoteMeta(AnswersNamespace) + `/answers\.[0-9a-f]{32}$`) + for item, secret := range store { + if !account.MatchString(item) || strings.Contains(item, "build") || strings.Contains(item, "other") { + t.Fatal("an item's account is not a digest of the connection") + } + if strings.Contains(secret, "devbox") || strings.Contains(secret, "Password") { + t.Fatal("an item's secret names the host or the question") + } + } + + if err := ChangeAnswers(ctx, store, "build", []AnswerChange{{Question: password, Forget: true}}); err != nil { + t.Fatal(err) + } + if _, found, _ := RememberedAnswer(ctx, store, "build", password); found { + t.Fatal("a forgotten answer is still found") + } + if answer, _, _ := RememberedAnswer(ctx, store, "build", passphrase); answer != "phrase" { + t.Fatalf("forgetting the password lost the passphrase: %q", answer) + } + if err := ChangeAnswers(ctx, store, "build", []AnswerChange{{Question: passphrase, Forget: true}}); err != nil { + t.Fatal(err) + } + if err := ForgetAnswers(ctx, store, "other"); err != nil { + t.Fatal(err) + } + if len(store) != 0 { + t.Fatalf("empty lists left %d items", len(store)) + } + if err := ForgetAnswers(ctx, store, "other"); err != nil { + t.Fatalf("forgetting a connection that remembers nothing failed: %v", err) + } +} + +// Changes that leave the list as it was write nothing, so a connection whose answers did not +// change does not touch the store. +func TestUnchangedAnswersWriteNothing(t *testing.T) { + ctx := testContext(t) + question := AnswerQuestion(core.RemoteQuestionPassword, devbox, "Password: ") + store := cappedStore{keptStore: keptStore{}, limit: 1 << 20} + if err := ChangeAnswers(ctx, store, "build", []AnswerChange{{Question: question, Answer: "s3cret"}}); err != nil { + t.Fatal(err) + } + // A store that refuses every write shows whether one is attempted. + store.limit = 0 + for _, changes := range [][]AnswerChange{ + nil, + {{Question: question, Answer: "s3cret"}}, + {{Question: "not-remembered", Forget: true}}, + } { + if err := ChangeAnswers(ctx, store, "build", changes); err != nil { + t.Fatalf("%+v wrote to the store: %v", changes, err) + } + } +} + +// A list beyond the limit forgets its oldest answers; a list the store cannot hold keeps only the +// newest; a secret that does not decode reads as no answer and is replaced by the next change. +func TestRememberedAnswersStayWithinTheStore(t *testing.T) { + ctx, store := testContext(t), keptStore{} + for n := 1; n <= answersLimit+2; n++ { + if err := ChangeAnswers(ctx, store, "build", []AnswerChange{{Question: fmt.Sprintf("q%d", n), Answer: fmt.Sprintf("a%d", n)}}); err != nil { + t.Fatal(err) + } + } + for n := 1; n <= answersLimit+2; n++ { + _, found, _ := RememberedAnswer(ctx, store, "build", fmt.Sprintf("q%d", n)) + if want := n > 2; found != want { + t.Errorf("answer %d found %v, want %v", n, found, want) + } + } + + capped := cappedStore{keptStore: keptStore{}, limit: 120} + for _, n := range []int{1, 2, 3} { + if err := ChangeAnswers(ctx, capped, "build", []AnswerChange{{Question: fmt.Sprintf("q%d", n), Answer: strings.Repeat("x", 30)}}); err != nil { + t.Fatal(err) + } + } + if _, found, _ := RememberedAnswer(ctx, capped, "build", "q3"); !found { + t.Fatal("the newest answer was not kept when the list was too large") + } + if _, found, _ := RememberedAnswer(ctx, capped, "build", "q1"); found { + t.Fatal("a list too large for the store kept its oldest answer") + } + if err := ChangeAnswers(ctx, capped, "build", []AnswerChange{{Question: "q4", Answer: strings.Repeat("x", 200)}}); err == nil { + t.Fatal("an answer the store cannot hold on its own was reported remembered") + } + + store[AnswersNamespace+"/"+answersAccount("broken")] = "not json" + if _, found, err := RememberedAnswer(ctx, store, "broken", "q1"); err != nil || found { + t.Fatalf("an undecodable secret found an answer, %v", err) + } + if err := ChangeAnswers(ctx, store, "broken", []AnswerChange{{Question: "q1", Answer: "a1"}}); err != nil { + t.Fatal(err) + } + if answer, _, _ := RememberedAnswer(ctx, store, "broken", "q1"); answer != "a1" { + t.Fatalf("the undecodable secret was not replaced: %q", answer) + } +} diff --git a/desktop/internal/remoteconn/kept.go b/desktop/internal/remoteconn/kept.go index 960485256..aea9d75f3 100644 --- a/desktop/internal/remoteconn/kept.go +++ b/desktop/internal/remoteconn/kept.go @@ -31,9 +31,10 @@ const KeptNamespace = "@host/remote-sessions" // keptLimit is how many kept sessions one connection remembers. const keptLimit = 8 -// KeptSecrets is the secret store the kept sessions are remembered in, credentials.Store in the -// application. Get reports found false for an item that is not there. -type KeptSecrets interface { +// Secrets is the secret store the kept sessions and the remembered answers (answers.go) are +// kept in, credentials.Store in the application. Get reports found false for an item that is not +// there. +type Secrets interface { Get(ctx context.Context, namespace, key string) (string, bool, error) Set(ctx context.Context, namespace, key, secret string) error Delete(ctx context.Context, namespace, key string) error @@ -52,7 +53,7 @@ func keptAccount(connectionID string) string { // readKept is connectionID's list, oldest first. A secret that does not decode holds no session // that can be resumed, so it reads as an empty list, which the next change replaces. -func readKept(ctx context.Context, secrets KeptSecrets, connectionID string) ([]core.RemoteResume, error) { +func readKept(ctx context.Context, secrets Secrets, connectionID string) ([]core.RemoteResume, error) { secret, found, err := secrets.Get(ctx, KeptNamespace, keptAccount(connectionID)) if err != nil || !found { return nil, err @@ -65,7 +66,7 @@ func readKept(ctx context.Context, secrets KeptSecrets, connectionID string) ([] } // writeKept stores kept as connectionID's list, removing the item when it is empty. -func writeKept(ctx context.Context, secrets KeptSecrets, connectionID string, kept []core.RemoteResume) error { +func writeKept(ctx context.Context, secrets Secrets, connectionID string, kept []core.RemoteResume) error { account := keptAccount(connectionID) if len(kept) == 0 { return secrets.Delete(ctx, KeptNamespace, account) @@ -78,7 +79,7 @@ func writeKept(ctx context.Context, secrets KeptSecrets, connectionID string, ke } // NewestKept is the session connectionID kept last, nil when it keeps none. -func NewestKept(ctx context.Context, secrets KeptSecrets, connectionID string) (*core.RemoteResume, error) { +func NewestKept(ctx context.Context, secrets Secrets, connectionID string) (*core.RemoteResume, error) { keptLock.Lock() defer keptLock.Unlock() kept, err := readKept(ctx, secrets, connectionID) @@ -91,7 +92,7 @@ func NewestKept(ctx context.Context, secrets KeptSecrets, connectionID string) ( // RememberKept adds resume as connectionID's newest kept session, replacing an entry of the same // key and forgetting the oldest beyond keptLimit. -func RememberKept(ctx context.Context, secrets KeptSecrets, connectionID string, resume core.RemoteResume) error { +func RememberKept(ctx context.Context, secrets Secrets, connectionID string, resume core.RemoteResume) error { keptLock.Lock() defer keptLock.Unlock() kept, err := readKept(ctx, secrets, connectionID) @@ -108,7 +109,7 @@ func RememberKept(ctx context.Context, secrets KeptSecrets, connectionID string, // ForgetKept removes the session key from connectionID's list; forgetting one that is not there // succeeds. -func ForgetKept(ctx context.Context, secrets KeptSecrets, connectionID, key string) error { +func ForgetKept(ctx context.Context, secrets Secrets, connectionID, key string) error { keptLock.Lock() defer keptLock.Unlock() kept, err := readKept(ctx, secrets, connectionID) diff --git a/desktop/internal/workbench/app.go b/desktop/internal/workbench/app.go index e6f9483ee..392947886 100644 --- a/desktop/internal/workbench/app.go +++ b/desktop/internal/workbench/app.go @@ -829,9 +829,9 @@ type App struct { remoteBundle func() (remoteserver.Bundle, error) remoteAnchor func() (string, error) remoteAfter func(time.Duration, func()) func() bool - // remoteKeptSecrets replaces the platform secret store the kept host sessions are remembered + // remoteSecretStore replaces the platform secret store the kept host sessions are remembered // in (remote_close.go); tests set it. - remoteKeptSecrets remoteconn.KeptSecrets + remoteSecretStore remoteconn.Secrets // gitAuth holds the questions of the Git operations the user started (git_auth.go). gitAuth gitAuthState newProject newProjectState diff --git a/desktop/internal/workbench/app_test.go b/desktop/internal/workbench/app_test.go index 6ff60b0da..ae18b6770 100644 --- a/desktop/internal/workbench/app_test.go +++ b/desktop/internal/workbench/app_test.go @@ -112,7 +112,7 @@ func newHarnessWithDriver(t testing.TB, options Options, open func(app.Config) ( } h.app = New(options) // Kept host sessions are remembered in memory, never in this computer's secret store. - h.app.remoteKeptSecrets = &memoryKeptSecrets{} + h.app.remoteSecretStore = &memorySecrets{} h.config = h.app.Config() driver, closeDriver, err := open(h.config) if err != nil { diff --git a/desktop/internal/workbench/git_auth.go b/desktop/internal/workbench/git_auth.go index d155de6cb..ad3e6a801 100644 --- a/desktop/internal/workbench/git_auth.go +++ b/desktop/internal/workbench/git_auth.go @@ -20,7 +20,8 @@ import ( // follows; a question leaves the queue once it is answered or its request has returned. // // The SSH client of a remote connection asks through the same queue and dialog (core.RemoteProbe -// marks its questions Remote): only the title, the hint and the command that answers differ. +// marks its questions Remote): only the title, the hint and the command that answers differ. A +// saved SSH connection adds a Remember box under a password or passphrase (remote_answers.go). const ( // gitAuthRespondTimeout bounds passing one answer to Core, which replies at once. @@ -32,15 +33,44 @@ const ( // gitAuthState is what the window keeps of the questions Git is waiting on. type gitAuthState struct { // queue is every question still waiting, the first asked first. - queue []core.GitAuthChallenge - // field holds what is typed for queue[0]. Each question gets a field of its own (fieldFor - // names it), so neither an answer nor its undo history outlives the question. + queue []gitAuthQuestion + // field holds what is typed for queue[0], and remember is its Remember box. Each question + // gets a field of its own (fieldFor names it), so neither an answer nor its undo history + // outlives the question. field ui.Field + remember bool fieldFor string // open is the dialog's flag; the dialog is open while the queue is not empty. open bool } +// gitAuthQuestion is a question waiting in the window: Core's challenge and, for a saved SSH +// connection, what the connection remembers of it. +type gitAuthQuestion struct { + core.GitAuthChallenge + // answers is what the asking connection remembers and learns, nil when it remembers nothing. + answers *remoteAnswers + // question is the digest its answer is remembered under, empty when none may be. + question string + // remembered says an answer is remembered for it, or was chosen to be in this connection, so + // its Remember box starts ticked. + remembered bool + // refused says OpenSSH asked it again after the remembered answer was sent on its own. + refused bool +} + +// rememberable says whether the answer may be remembered, so the window shows a Remember box. +func (q gitAuthQuestion) rememberable() bool { + return q.answers != nil && q.question != "" +} + +// answering makes the field and the Remember box head's own as head becomes the first question. +func (g *gitAuthState) answering(head gitAuthQuestion) { + if g.fieldFor != head.RequestID { + g.field, g.remember, g.fieldFor = ui.Field{}, head.remembered, head.RequestID + } +} + // gitAuthentication returns ctx with this window as the prompt for the questions of the Git // operation it carries. Give it only to an operation the user started, never to an automatic // refresh: Core lets that one fail instead of asking. The prompt runs on the request's @@ -48,7 +78,7 @@ type gitAuthState struct { // request has returned. func (a *App) gitAuthentication(ctx context.Context) context.Context { return core.WithGitAuthentication(ctx, func(challenge core.GitAuthChallenge) { - a.post(func(a *App) { a.gitAuth.queue = append(a.gitAuth.queue, challenge) }) + a.post(func(a *App) { a.gitAuth.queue = append(a.gitAuth.queue, gitAuthQuestion{GitAuthChallenge: challenge}) }) go func() { <-challenge.Done a.post(func(a *App) { a.dropGitAuth(challenge.RequestID) }) @@ -60,9 +90,9 @@ func (a *App) gitAuthentication(ctx context.Context) context.Context { // for it. func (a *App) dropGitAuth(requestID string) { g := &a.gitAuth - g.queue = slices.DeleteFunc(g.queue, func(challenge core.GitAuthChallenge) bool { return challenge.RequestID == requestID }) + g.queue = slices.DeleteFunc(g.queue, func(question gitAuthQuestion) bool { return question.RequestID == requestID }) if g.fieldFor == requestID { - g.field, g.fieldFor = ui.Field{}, "" + g.field, g.remember, g.fieldFor = ui.Field{}, false, "" } } @@ -80,9 +110,7 @@ func (a *App) gitAuthDialog(c ui.C) { // The Remote Development window asks it under the step of the connection that asks it. return } - if g.fieldFor != head.RequestID { - g.field, g.fieldFor = ui.Field{}, head.RequestID - } + g.answering(head) lang := a.language() g.open = true submitted, cancelled, confirmed := false, false, false @@ -96,10 +124,7 @@ func (a *App) gitAuthDialog(c ui.C) { ui.Wrap(c, i18n.Shared(lang, "desktop.gitAuth.retryMessage")) } else { ui.Wrap(c, strings.TrimSpace(head.Prompt)) - if head.Attempt > 1 { - ui.Wrap(c, i18n.SharedFormat(lang, "desktop.gitAuth.again", map[string]string{"attempt": strconv.Itoa(head.Attempt)})). - FontSize(12).Color(a.colors.Warning) - } + a.gitAuthAgain(c, lang, head, 12) // The field is the question's own part, so it takes the focus again for the next // question as it appears. field := ui.TextField(c.Part(head.RequestID), &g.field, i18n.Shared(lang, "desktop.gitAuth.answer"), "").FillWidth().AutoFocus() @@ -107,13 +132,7 @@ func (a *App) gitAuthDialog(c ui.C) { field = field.Secure() } submitted = field.Submitted() - if head.Secret { - hint := i18n.Shared(lang, "desktop.gitAuth.secretHint") - if head.Remote { - hint = i18n.Shared(lang, "desktop.remoteAuth.secretHint") - } - ui.Wrap(c, hint).FontSize(12).Color(a.colors.Subtle) - } + a.gitAuthKeeping(c, lang, head, 12) } if head.WorkingDirectory != "" { ui.Wrap(c, i18n.SharedFormat(lang, "desktop.gitAuth.directory", map[string]string{"path": head.WorkingDirectory})). @@ -136,12 +155,47 @@ func (a *App) gitAuthDialog(c ui.C) { } } +// gitAuthAgain declares, at size, that the question is asked again: the remembered answer was +// refused, or what was typed before. +func (a *App) gitAuthAgain(c ui.C, lang i18n.Language, head gitAuthQuestion, size float32) { + switch { + case head.refused: + ui.Wrap(c, i18n.Shared(lang, "desktop.remoteAuth.rememberedRefused")).FontSize(size).Color(a.theme.Danger) + case head.Attempt > 1: + ui.Wrap(c, i18n.SharedFormat(lang, "desktop.gitAuth.again", map[string]string{"attempt": strconv.Itoa(head.Attempt)})). + FontSize(size).Color(a.colors.Warning) + } +} + +// gitAuthKeeping declares, at size, what happens to a secret answer: the Remember box of one a +// saved connection may remember, with where it is kept once ticked, or that it is not kept. +func (a *App) gitAuthKeeping(c ui.C, lang i18n.Language, head gitAuthQuestion, size float32) { + g := &a.gitAuth + if head.rememberable() { + label := i18n.Shared(lang, "desktop.remoteAuth.rememberPassword") + if head.Kind == core.RemoteQuestionPassphrase { + label = i18n.Shared(lang, "desktop.remoteAuth.rememberPassphrase") + } + ui.Checkbox(c.Part("remember"), &g.remember, label) + } + switch { + case head.rememberable() && g.remember: + ui.Wrap(c, i18n.Shared(lang, "desktop.remoteAuth.rememberHint")).FontSize(size).Color(a.colors.Subtle) + case !head.Secret: + case head.Remote: + ui.Wrap(c, i18n.Shared(lang, "desktop.remoteAuth.secretHint")).FontSize(size).Color(a.colors.Subtle) + default: + ui.Wrap(c, i18n.Shared(lang, "desktop.gitAuth.secretHint")).FontSize(size).Color(a.colors.Subtle) + } +} + // answerGitAuth answers the question requestID if it is still the first: with what was typed, // or with core.GitRetryAnswer for the retry question, when confirm is set, and otherwise cancels -// it. The question leaves the queue at once; Core's verdict arrives later. An answer Core no -// longer takes is for a question that expired or whose request returned, and the dialog has -// moved on; an answer Core refused, too long or with a line break, cancels the question and -// says why. +// it. The question leaves the queue at once; Core's verdict arrives later. The answer to a question +// its connection may remember is remembered or forgotten, as the Remember box says, once the +// connection ends (remoteAnswers.settle). An answer Core no longer takes is for a question that +// expired or whose request returned, and the dialog has moved on; an answer Core refused, too +// long or with a line break, cancels the question and says why. func (a *App) answerGitAuth(requestID string, confirm bool) { g := &a.gitAuth if len(g.queue) == 0 || g.queue[0].RequestID != requestID { @@ -162,8 +216,13 @@ func (a *App) answerGitAuth(requestID string, confirm bool) { case confirm: typed := g.field.Text() answer, action = &typed, kind+"answer" + if head.rememberable() { + head.answers.choose(head, typed, g.remember) + } + case head.answers != nil: + head.answers.cancel() } - g.field, g.fieldFor = ui.Field{}, "" + g.field, g.remember, g.fieldFor = ui.Field{}, false, "" a.performed(action, surfaceButton) a.background(nil, gitAuthRespondTimeout, func(ctx context.Context) func(*App) { accepted, err := respond(ctx, head.RequestID, answer) diff --git a/desktop/internal/workbench/git_auth_test.go b/desktop/internal/workbench/git_auth_test.go index b17f8ef40..8987c8640 100644 --- a/desktop/internal/workbench/git_auth_test.go +++ b/desktop/internal/workbench/git_auth_test.go @@ -77,9 +77,9 @@ func (h *harness) typeText(value string) { // awaitGitQuestion waits until the window shows a question that asked holds and paints it // with the field focused. -func (h *harness) awaitGitQuestion(what string, asked func(core.GitAuthChallenge) bool) core.GitAuthChallenge { +func (h *harness) awaitGitQuestion(what string, asked func(core.GitAuthChallenge) bool) gitAuthQuestion { h.t.Helper() - h.await(what, func() bool { return len(h.app.gitAuth.queue) > 0 && asked(h.app.gitAuth.queue[0]) }) + h.await(what, func() bool { return len(h.app.gitAuth.queue) > 0 && asked(h.app.gitAuth.queue[0].GitAuthChallenge) }) for range 2 { if err := h.driver.Pump(); err != nil { h.t.Fatal(err) @@ -205,7 +205,9 @@ func gitAuthHarness(t *testing.T, accept func(*string) bool, challenges ...core. h := newHarnessWithLanguages(t, kernel, []string{"en-US"}) logger := &treeRecordingLog{} h.app.logSink = logger - h.app.gitAuth.queue = challenges + for _, challenge := range challenges { + h.app.gitAuth.queue = append(h.app.gitAuth.queue, gitAuthQuestion{GitAuthChallenge: challenge}) + } h.app.invalidator.Invalidate() h.settle() h.settle() diff --git a/desktop/internal/workbench/git_auth_visual_test.go b/desktop/internal/workbench/git_auth_visual_test.go index 122734869..67e92d2d4 100644 --- a/desktop/internal/workbench/git_auth_visual_test.go +++ b/desktop/internal/workbench/git_auth_visual_test.go @@ -40,7 +40,9 @@ func TestVisualGitAuthentication(t *testing.T) { name := "git-auth-" + state.name + "-" + scene.theme + "-" + scene.language t.Run(name, func(t *testing.T) { h, session := visualGitAuthHarness(t, scene.theme, scene.language) - h.app.post(func(a *App) { a.gitAuth.queue = append(a.gitAuth.queue, state.challenge) }) + h.app.post(func(a *App) { + a.gitAuth.queue = append(a.gitAuth.queue, gitAuthQuestion{GitAuthChallenge: state.challenge}) + }) h.settle() h.settle() if state.typed != "" { diff --git a/desktop/internal/workbench/remote.go b/desktop/internal/workbench/remote.go index b9bb61e42..250dc680c 100644 --- a/desktop/internal/workbench/remote.go +++ b/desktop/internal/workbench/remote.go @@ -628,6 +628,16 @@ func (a *App) removeRemote() { a.editRemote("remote_connection_remove", core.RemoteConnectionEdit{Remove: &core.RemoteConnectionID{ID: r.selected}}) } +// forgetRemovedRemote forgets the answers the deleted connection id remembered, which no +// connection can use any more. +func (a *App) forgetRemovedRemote(id string) { + secrets := a.remoteSecrets() + a.background(nil, remoteReadTimeout, func(ctx context.Context) func(*App) { + err := remoteconn.ForgetAnswers(ctx, secrets, id) + return func(a *App) { a.remoteAnswersSettled(err, true) } + }) +} + // editRemote applies edit to the list as it was read, in the background. site names the // operation in the log. func (a *App) editRemote(site string, edit core.RemoteConnectionEdit) { @@ -685,6 +695,7 @@ func (a *App) editRemote(site string, edit core.RemoteConnectionEdit) { r.setSource(after) a.loadRemoteImportCounts() if edit.Remove != nil { + a.forgetRemovedRemote(edit.Remove.ID) r.selectFirst() return } @@ -741,15 +752,20 @@ func (a *App) testRemote() { ctx, cancel := context.WithTimeout(a.operationContext(context.Background()), remoteProbeTimeout) probe := &remoteProbe{cancel: cancel} r.probe = probe + // A saved connection's test remembers its answers as connecting does, under the questions of + // the login the form holds. + answers := a.remoteAnswersFor(r.selected, remoteHost{ssh: connection}) generation, kernel, root := r.generation, a.kernel, a.globalToolchainRoot() a.background(nil, 0, func(context.Context) func(*App) { defer cancel() var result core.RemoteProbeResult preferences, err := remotePreferencesDocument(ctx, kernel, root) if err == nil { - result, err = kernel.RemoteProbe(a.gitAuthentication(ctx), connection, preferences) + result, err = kernel.RemoteProbe(a.remoteAuthentication(ctx, answers, true), connection, preferences) } + settled := answers.settle(result.Status, err) return func(a *App) { + a.remoteAnswersSettled(settled, true) r := &a.remote if !r.open || r.generation != generation || r.probe != probe { // log-exempt: 用户取消:测试已停止、换了连接或窗口已关闭,不再应用结果。 diff --git a/desktop/internal/workbench/remote_answers.go b/desktop/internal/workbench/remote_answers.go new file mode 100644 index 000000000..4f07ce38a --- /dev/null +++ b/desktop/internal/workbench/remote_answers.go @@ -0,0 +1,248 @@ +package workbench + +import ( + "context" + "strings" + "sync" + + "github.com/1lck/Lithe-IDEA/desktop/internal/core" + "github.com/1lck/Lithe-IDEA/desktop/internal/i18n" + "github.com/1lck/Lithe-IDEA/desktop/internal/remoteconn" +) + +// A saved SSH connection remembers a password or key passphrase only when the user ticks Remember +// under the question (#2231, S12; remoteconn/answers.go). What a connection learns is applied once +// it has ended: +// +// - A remembered answer is sent on its own only the first time OpenSSH asks its question in a +// connection. When OpenSSH asks again, or the login fails without anything cancelled, the host +// refused it: it is forgotten whatever the connection's outcome, and the window asks. +// - An answer typed with Remember ticked is stored only once the connection logs in, so a +// mistyped password is never stored. Typing one with Remember unticked forgets the remembered +// answer even when the connection fails. +// +// A WSL distribution and a container of this computer ask nothing, and a connection that is not +// saved has no id to remember under, so neither remembers. A container on a saved SSH host logs +// in to the host, so it uses the host's answers. An automatic reconnection asks nothing: it sends +// what is remembered and cancels every other question, as Core does without a prompt. + +// remoteAnswersSite names the remembered answers in the log; the events carry only the error. +const remoteAnswersSite = "remote_answers" + +// remoteAnswers is what one connection to a saved SSH host remembers and learns. +type remoteAnswers struct { + secrets remoteconn.Secrets + kernel Kernel + // owner is the saved connection the answers are remembered under; login is how this + // connection logs in, which the questions' digests include. + owner string + login core.SSHConnection + + mu sync.Mutex + // sent are the questions answered on their own with the remembered answer. + sent map[string]bool + // refused are the questions OpenSSH asked again after the remembered answer was sent. + refused map[string]bool + // cancelled says a question of this connection went unanswered, so a failed login says + // nothing about the answers that were sent. + cancelled bool + // choices are the user's Remember choices, in the order made. + choices []remoteconn.AnswerChange +} + +// remoteAnswersFor is what the connection named connectionID to host remembers, nil when it +// remembers nothing: host is not reached over SSH, or the connection is not saved. Saved ids +// never contain "/" (Core allows letters, digits and "-"), so the id of a container on a saved +// host starts with the host's id and a "/" (remoteHostContainerTarget). +func (a *App) remoteAnswersFor(connectionID string, host remoteHost) *remoteAnswers { + owner, _, _ := strings.Cut(connectionID, "/") + if owner == "" || !host.overSSH() { + return nil + } + return &remoteAnswers{secrets: a.remoteSecrets(), kernel: a.kernel, owner: owner, login: remoteStored(host.ssh)} +} + +// remoteAuthentication returns ctx with the prompt of a connection's OpenSSH questions: what +// answers remembers is sent on its own; with ask set every other question reaches the window as +// gitAuthentication posts it, and otherwise it is cancelled. Without answers it is +// gitAuthentication, or ctx itself when nothing asks. It may be called on any goroutine. +func (a *App) remoteAuthentication(ctx context.Context, answers *remoteAnswers, ask bool) context.Context { + switch { + case answers == nil && ask: + return a.gitAuthentication(ctx) + case answers == nil: + return ctx + } + return core.WithGitAuthentication(ctx, a.remotePrompt(ctx, answers, ask)) +} + +// remotePrompt is remoteAuthentication's prompt for the questions of the request ctx carries. +func (a *App) remotePrompt(ctx context.Context, answers *remoteAnswers, ask bool) func(core.GitAuthChallenge) { + return func(challenge core.GitAuthChallenge) { + // Reading the store takes a moment, and the request's goroutine must not wait on it. + go func() { + question, answered, err := answers.offer(ctx, challenge) + if err != nil && ctx.Err() == nil { + a.post(func(a *App) { a.backgroundFailed(remoteAnswersSite, err) }) + } + if answered || requestReturned(challenge.Done) { + return + } + if !ask { + answers.cancel() + // log-exempt: 用户取消:自动重连不询问,与 Core 在没有询问者时一样取消这个问题;重连的结果另记 remote_reconnect。 + _, _ = answers.kernel.RemoteAuthRespond(context.Background(), challenge.RequestID, nil) + return + } + a.post(func(a *App) { a.gitAuth.queue = append(a.gitAuth.queue, question) }) + <-challenge.Done + a.post(func(a *App) { a.dropGitAuth(challenge.RequestID) }) + }() + } +} + +// remoteLoggedIn reports whether a test or connection that ended with status and err logged in +// to the host: it connected, or the host turned out to be one no server build runs on. +func remoteLoggedIn(status core.RemoteProbeStatus, err error) bool { + return err == nil && (status == core.RemoteProbeConnected || status == core.RemoteProbeUnsupportedPlatform) +} + +// offer sends the remembered answer when OpenSSH asks its question for the first time in this +// connection; answered reports that it was taken. Otherwise question is how the window asks it. +// err is a failure of the store or of Core, after which the window asks. +func (s *remoteAnswers) offer(ctx context.Context, challenge core.GitAuthChallenge) (question gitAuthQuestion, answered bool, err error) { + question = gitAuthQuestion{GitAuthChallenge: challenge, answers: s} + if challenge.Retry || !remoteconn.Rememberable(challenge.Kind) { + return question, false, nil + } + question.question = remoteconn.AnswerQuestion(challenge.Kind, s.login, challenge.Prompt) + s.mu.Lock() + sent := s.sent[question.question] + if sent && challenge.Attempt > 1 { + if s.refused == nil { + s.refused = map[string]bool{} + } + s.refused[question.question] = true + question.refused = true + } + chosen, choseRemember := s.choice(question.question) + s.mu.Unlock() + if chosen { + question.remembered = choseRemember + return question, false, nil + } + answer, found, err := remoteconn.RememberedAnswer(ctx, s.secrets, s.owner, question.question) + if err != nil || !found { + return question, false, err + } + question.remembered = true + if sent || challenge.Attempt > 1 { + return question, false, nil + } + accepted, err := s.kernel.RemoteAuthRespond(ctx, challenge.RequestID, &answer) + if err != nil || !accepted { + // Core takes any remembered answer, which it once took; one it no longer takes is asked. + return question, false, err + } + s.mu.Lock() + if s.sent == nil { + s.sent = map[string]bool{} + } + s.sent[question.question] = true + s.mu.Unlock() + return question, true, nil +} + +// choice is the user's last Remember choice for question in this connection; chosen is false +// when none was made. s.mu is held. +func (s *remoteAnswers) choice(question string) (chosen, remember bool) { + for _, change := range s.choices { + if change.Question == question { + chosen, remember = true, !change.Forget + } + } + return chosen, remember +} + +// choose records the user's answer to question: remembered once the connection succeeds when +// remember is set, otherwise forgotten if it was remembered. +func (s *remoteAnswers) choose(question gitAuthQuestion, answer string, remember bool) { + s.mu.Lock() + defer s.mu.Unlock() + switch { + case remember && answer != "": + s.choices = append(s.choices, remoteconn.AnswerChange{Question: question.question, Answer: answer}) + case question.remembered: + s.choices = append(s.choices, remoteconn.AnswerChange{Question: question.question, Forget: true}) + } +} + +// cancel records that a question of this connection went unanswered. +func (s *remoteAnswers) cancel() { + s.mu.Lock() + s.cancelled = true + s.mu.Unlock() +} + +// settle applies what the connection learned once it ended with status and err (remoteLoggedIn). +// It runs off the window thread, within remoteReadTimeout of its own since the connection may +// have been stopped; a nil s settles nothing. +func (s *remoteAnswers) settle(status core.RemoteProbeStatus, err error) error { + if s == nil { + return nil + } + ctx, cancel := context.WithTimeout(context.Background(), remoteReadTimeout) + defer cancel() + s.mu.Lock() + var changes []remoteconn.AnswerChange + forget := func(questions map[string]bool) { + for question := range questions { + changes = append(changes, remoteconn.AnswerChange{Question: question, Forget: true}) + } + } + loggedIn := remoteLoggedIn(status, err) + forget(s.refused) + if err == nil && status == core.RemoteProbeAuthenticationFailed && !s.cancelled { + forget(s.sent) + } + for _, change := range s.choices { + if change.Forget || loggedIn { + changes = append(changes, change) + } + } + s.sent, s.refused, s.cancelled, s.choices = nil, nil, false, nil + s.mu.Unlock() + return remoteconn.ChangeAnswers(ctx, s.secrets, s.owner, changes) +} + +// remoteAnswersSettled reports, on the window thread, a failure of settle; userStarted says the +// user started the connection, which the user is told about. +func (a *App) remoteAnswersSettled(err error, userStarted bool) { + switch { + case err == nil: + case userStarted: + a.operationFailed(remoteAnswersSite, err) + a.notifyError(i18n.SharedFormat(a.language(), "desktop.remoteAuth.rememberFailed", map[string]string{"reason": err.Error()})) + default: + a.backgroundFailed(remoteAnswersSite, err) + } +} + +// forgetRemoteAnswers forgets every answer the saved connection entry remembers. +func (a *App) forgetRemoteAnswers(entry core.SavedRemoteConnection) { + if !a.remote.open { + return + } + a.performed("remote.connection.forgetAnswers", surfaceMenu) + secrets, id, name := a.remoteSecrets(), entry.ID, entry.Name + a.background(nil, remoteReadTimeout, func(ctx context.Context) func(*App) { + err := remoteconn.ForgetAnswers(ctx, secrets, id) + return func(a *App) { + if err != nil { + a.remoteAnswersSettled(err, true) + return + } + a.notifyInfo(i18n.SharedFormat(a.language(), "desktop.remote.answersForgotten", map[string]string{"name": name})) + } + }) +} diff --git a/desktop/internal/workbench/remote_answers_test.go b/desktop/internal/workbench/remote_answers_test.go new file mode 100644 index 000000000..13d20fd52 --- /dev/null +++ b/desktop/internal/workbench/remote_answers_test.go @@ -0,0 +1,419 @@ +package workbench + +import ( + "context" + "os" + "path/filepath" + "runtime" + "slices" + "strings" + "sync" + "testing" + "time" + + "github.com/1lck/Lithe-IDEA/desktop/internal/core" + "github.com/1lck/Lithe-IDEA/desktop/internal/i18n" + "github.com/1lck/Lithe-IDEA/desktop/internal/remoteconn" + "github.com/vivaui/viva/gfx" +) + +// standInSSHAccepting puts an ssh on PATH that asks OpenSSH's password question up to three times +// through the AskPass helper Core names, as OpenSSH does after a wrong password, and runs the +// remote command with the local shell once the answer is the password accept sets. A cancelled +// question, or three wrong answers, fail like a server rejecting them. +func standInSSHAccepting(t *testing.T) (accept func(string)) { + t.Helper() + if runtime.GOOS == "windows" { + t.Skip("the stand-in SSH client is a POSIX shell script") + } + dir := t.TempDir() + script := `#!/bin/sh +for last; do :; done +accept=$(cat "$(dirname "$0")/accept") +for attempt in 1 2 3; do + answer=$("$SSH_ASKPASS" "dev@devbox's password: ") || break + if [ "$answer" = "$accept" ]; then + exec /bin/sh -c "$last" + fi + echo 'Permission denied, please try again.' >&2 +done +echo 'dev@devbox: Permission denied (password).' >&2 +exit 255 +` + if err := os.WriteFile(filepath.Join(dir, "ssh"), []byte(script), 0o755); err != nil { + t.Fatal(err) + } + t.Setenv("PATH", dir+string(os.PathListSeparator)+os.Getenv("PATH")) + return func(password string) { + t.Helper() + if err := os.WriteFile(filepath.Join(dir, "accept"), []byte(password), 0o600); err != nil { + t.Fatal(err) + } + } +} + +// saveRemoteDevbox saves dev@devbox from the empty page and returns its id, selected. +func saveRemoteDevbox(t *testing.T, h *harness) string { + t.Helper() + r := &h.app.remote + h.clickLabeled(i18n.Shared(h.app.language(), "desktop.remote.new")) + r.form.host.SetText("devbox") + r.form.user.SetText("dev") + h.redraw() + h.clickLabeled(i18n.Shared(h.app.language(), "desktop.remote.save")) + h.settle() + if r.entry(r.selected) == nil || r.dirty() { + t.Fatal("the connection was not saved and selected") + } + return r.selected +} + +// remoteAnswersContext bounds a test's reads and writes of the secret store. +func remoteAnswersContext(t *testing.T) context.Context { + t.Helper() + ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + t.Cleanup(cancel) + return ctx +} + +// rememberedAnswers are the secrets the store keeps for remembered answers. +func rememberedAnswers(store *memorySecrets) []string { + store.mu.Lock() + defer store.mu.Unlock() + var secrets []string + for item, secret := range store.items { + if strings.HasPrefix(item, remoteconn.AnswersNamespace+"\x00") { + secrets = append(secrets, secret) + } + } + return secrets +} + +// clickNow clicks the control named label and paints what it did, without waiting for background +// work: a test that waits on a question runs until the question is answered. +func (h *harness) clickNow(label string) { + h.t.Helper() + point := center(h.hitLabeled(label)) + if err := h.driver.Click(point.X, point.Y); err != nil { + h.t.Fatal(err) + } + for range 2 { + if err := h.driver.Pump(); err != nil { + h.t.Fatal(err) + } + } +} + +// testSavedRemote tests the selected saved connection and waits for its outcome, which logged in +// to the local machine: it connected, or found no server build for it. +func (h *harness) testSavedRemote(what string) { + h.t.Helper() + r := &h.app.remote + h.app.testRemote() + if r.probe == nil { + h.t.Fatal("the test did not start") + } + h.await(what, func() bool { return r.probe == nil && r.result != nil }) + h.settle() + if !remoteLoggedIn(r.result.result.Status, r.result.err) { + h.t.Fatalf("outcome = %+v, want a login", r.result) + } +} + +// A saved connection's password question has a Remember box, unticked. A password typed with it +// ticked is remembered once the login succeeds, never after it fails, and the next test logs in +// without asking. A remembered password the host refuses is asked again, saying so, with the box +// ticked; the new one replaces it, and unticking the box forgets it. Neither a password, the host +// nor OpenSSH's output is logged. +func TestRemoteRemembersAPasswordOnlyWhenTicked(t *testing.T) { + accept := standInSSHAccepting(t) + accept("s3cret") + h, logger := remoteHarness(t) + lang := h.app.language() + r := &h.app.remote + store := h.app.remoteSecretStore.(*memorySecrets) + saveRemoteDevbox(t, h) + remember := i18n.Shared(lang, "desktop.remoteAuth.rememberPassword") + submit := i18n.Shared(lang, "desktop.gitAuth.submit") + + // A mistyped password is not remembered although the box was ticked. + h.app.testRemote() + h.awaitGitQuestion("the password question", func(c core.GitAuthChallenge) bool { return c.Remote && c.Kind == core.RemoteQuestionPassword }) + if !h.shows(remember) || h.app.gitAuth.remember || h.showsWrapped(i18n.Shared(lang, "desktop.remoteAuth.rememberHint")) { + t.Fatal("the question does not offer an unticked Remember box") + } + h.typeText("wr0ng") + h.clickNow(remember) + if !h.app.gitAuth.remember || !h.showsWrapped(i18n.Shared(lang, "desktop.remoteAuth.rememberHint")) { + t.Fatal("ticking Remember does not say where the password is kept") + } + h.clickNow(submit) + h.awaitGitQuestion("the password question again", func(c core.GitAuthChallenge) bool { return c.Remote && c.Attempt == 2 }) + if !h.app.gitAuth.remember || h.showsWrapped(i18n.Shared(lang, "desktop.remoteAuth.rememberedRefused")) { + t.Fatal("the question asked again after a typed password lost the box or blamed a remembered one") + } + h.key(gfx.KeyEscape) + h.await("the test to fail", func() bool { return r.probe == nil && r.result != nil }) + h.settle() + if got := rememberedAnswers(store); len(got) != 0 { + t.Fatalf("a password the host refused was remembered: %d items", len(got)) + } + + // The right one, ticked, is remembered once the login succeeds, and answers the next test. + h.app.testRemote() + h.awaitGitQuestion("the password question", func(c core.GitAuthChallenge) bool { return c.Remote && c.Attempt == 1 }) + if h.app.gitAuth.remember { + t.Fatal("the box is ticked although nothing is remembered") + } + h.typeText("s3cret") + h.clickNow(remember) + h.clickNow(submit) + h.await("the test to finish", func() bool { return r.probe == nil && r.result != nil }) + h.settle() + if got := rememberedAnswers(store); len(got) != 1 || !strings.Contains(got[0], "s3cret") { + t.Fatal("the ticked password was not remembered after the login") + } + h.testSavedRemote("the test with the remembered password") + if len(h.app.gitAuth.queue) != 0 { + t.Fatal("the remembered password was asked for") + } + + // The host refuses the remembered password: asked again, ticked, and the new one replaces it. + accept("n3w") + h.app.testRemote() + h.awaitGitQuestion("the question after the refusal", func(c core.GitAuthChallenge) bool { return c.Remote && c.Attempt == 2 }) + if !h.showsWrapped(i18n.Shared(lang, "desktop.remoteAuth.rememberedRefused")) || !h.app.gitAuth.remember { + t.Fatal("the question does not say the remembered password was refused, with the box ticked") + } + h.typeText("n3w") + h.key(gfx.KeyEnter) + h.await("the test to finish", func() bool { return r.probe == nil && r.result != nil }) + h.settle() + if got := rememberedAnswers(store); len(got) != 1 || !strings.Contains(got[0], "n3w") || strings.Contains(got[0], "s3cret") { + t.Fatal("the new password did not replace the refused one") + } + + // Unticking the box forgets the password. + accept("l4st") + h.app.testRemote() + h.awaitGitQuestion("the question after the second refusal", func(c core.GitAuthChallenge) bool { return c.Remote && c.Attempt == 2 }) + h.typeText("l4st") + h.clickNow(remember) + h.clickNow(submit) + h.await("the test to finish", func() bool { return r.probe == nil && r.result != nil }) + h.settle() + if got := rememberedAnswers(store); len(got) != 0 { + t.Fatal("unticking Remember kept the password") + } + + want := []string{ + "remote.connections.open", "remote.connection.new", "remote.connection.save", + "remote.connection.test", "remote.authentication.answer", "remote.authentication.cancel", + "remote.connection.test", "remote.authentication.answer", + "remote.connection.test", + "remote.connection.test", "remote.authentication.answer", + "remote.connection.test", "remote.authentication.answer", + } + if got := remoteActions(logger); !slices.Equal(got, want) { + t.Fatalf("performed %q, want %q", got, want) + } + if event := loggedAny(t, logger, "wr0ng", "s3cret", "n3w", "l4st", "devbox", "Permission denied"); event != "" { + t.Fatalf("logged a password, the host or what OpenSSH said: %s", event) + } +} + +// Forget Remembered Passwords in the overview's ⋯ menu forgets what the connection remembers and +// says so; deleting the connection forgets it too. +func TestRemoteForgetsRememberedPasswords(t *testing.T) { + h, logger := remoteHarness(t) + lang := h.app.language() + r := &h.app.remote + store := h.app.remoteSecretStore.(*memorySecrets) + id := saveRemoteDevbox(t, h) + name := r.entry(id).Name + ctx := remoteAnswersContext(t) + seed := func() { + t.Helper() + if err := remoteconn.ChangeAnswers(ctx, store, id, []remoteconn.AnswerChange{{Question: "question", Answer: "s3cret"}}); err != nil { + t.Fatal(err) + } + } + + seed() + h.clickLabeled(i18n.Shared(lang, "desktop.remote.more")) + h.settle() + h.clickFront(i18n.Shared(lang, "desktop.remote.forgetAnswers")) + forgotten := i18n.SharedFormat(lang, "desktop.remote.answersForgotten", map[string]string{"name": name}) + h.await("the answers to be forgotten", func() bool { return slices.Contains(noticeTexts(h.app), forgotten) }) + if got := rememberedAnswers(store); len(got) != 0 { + t.Fatal("Forget Remembered Passwords kept the password") + } + + seed() + h.clickLabeled(i18n.Shared(lang, "desktop.remote.more")) + h.settle() + h.clickFront(i18n.SharedFormat(lang, "desktop.remote.deleteNamed", map[string]string{"name": name})) + h.settle() + h.clickLabeled(i18n.Shared(lang, "desktop.remote.delete")) + h.await("the deleted connection's answers to be forgotten", func() bool { return len(rememberedAnswers(store)) == 0 }) + h.settle() + if len(savedRemoteConnections(t, h)) != 0 { + t.Fatal("the connection was not deleted") + } + want := []string{ + "remote.connections.open", "remote.connection.new", "remote.connection.save", + "remote.connection.forgetAnswers", "remote.connection.deleteAsk", "remote.connection.remove", + } + if got := remoteActions(logger); !slices.Equal(got, want) { + t.Fatalf("performed %q, want %q", got, want) + } + if event := loggedAny(t, logger, "s3cret", "devbox"); event != "" { + t.Fatalf("logged a password or the host: %s", event) + } +} + +// remoteAnswerKernel records the answers sent to the questions of remote connections, and +// signals responded for each. +type remoteAnswerKernel struct { + *testKernel + responded chan struct{} + mu sync.Mutex + answers []*string +} + +func (k *remoteAnswerKernel) RemoteAuthRespond(_ context.Context, _ string, answer *string) (bool, error) { + k.mu.Lock() + k.answers = append(k.answers, answer) + k.mu.Unlock() + k.responded <- struct{}{} + return true, nil +} + +// awaitResponse waits for the next answer: an automatic one reaches Core without the window. +func (k *remoteAnswerKernel) awaitResponse(t *testing.T, what string) { + t.Helper() + select { + case <-k.responded: + case <-time.After(8 * time.Second): + t.Fatalf("timed out waiting for %s", what) + } +} + +// sent are the answers recorded, "" for a cancel. +func (k *remoteAnswerKernel) sent() []string { + k.mu.Lock() + defer k.mu.Unlock() + var sent []string + for _, answer := range k.answers { + if answer == nil { + sent = append(sent, "") + } else { + sent = append(sent, *answer) + } + } + return sent +} + +// An automatic reconnection sends the remembered password the first time OpenSSH asks and cancels +// every other question without showing it; a refused password is forgotten once it ends. +func TestRemoteReconnectionSendsOnlyTheRememberedPassword(t *testing.T) { + kernel := &remoteAnswerKernel{testKernel: &testKernel{Client: core.NewClient()}, responded: make(chan struct{}, 4)} + h := newHarnessWithLanguages(t, kernel, []string{"en-US"}) + store := h.app.remoteSecretStore.(*memorySecrets) + host := remoteHost{ssh: core.SSHConnection{Host: "devbox", User: "dev"}} + answers := h.app.remoteAnswersFor("build", host) + if h.app.remoteAnswersFor("", host) != nil || h.app.remoteAnswersFor("build", remoteHost{wsl: &core.WSLConnection{Distribution: "Ubuntu"}}) != nil { + t.Fatal("an unsaved connection or a WSL distribution remembers answers") + } + if other := h.app.remoteAnswersFor("build/container", host); other == nil || other.owner != "build" { + t.Fatal("a container on a saved host does not use the host's answers") + } + prompt := "dev@devbox's password: " + question := remoteconn.AnswerQuestion(core.RemoteQuestionPassword, answers.login, prompt) + ctx := remoteAnswersContext(t) + if err := remoteconn.ChangeAnswers(ctx, store, "build", []remoteconn.AnswerChange{{Question: question, Answer: "s3cret"}}); err != nil { + t.Fatal(err) + } + ask := h.app.remotePrompt(ctx, answers, false) + done := make(chan struct{}) + t.Cleanup(func() { close(done) }) + challenge := func(id string, kind core.RemoteQuestionKind, attempt int) core.GitAuthChallenge { + return core.GitAuthChallenge{RequestID: id, Prompt: prompt, Secret: true, Remote: true, Kind: kind, Attempt: attempt, Done: done} + } + for _, step := range []struct { + challenge core.GitAuthChallenge + want []string + }{ + {challenge("1", core.RemoteQuestionPassword, 1), []string{"s3cret"}}, + {challenge("2", core.RemoteQuestionPassword, 2), []string{"s3cret", ""}}, + {challenge("3", core.RemoteQuestionCode, 1), []string{"s3cret", "", ""}}, + } { + ask(step.challenge) + kernel.awaitResponse(t, "the answer to "+step.challenge.RequestID) + if got := kernel.sent(); !slices.Equal(got, step.want) { + t.Fatalf("sent %q, want %q", got, step.want) + } + } + h.settle() + if len(h.app.gitAuth.queue) != 0 { + t.Fatal("an automatic reconnection showed a question") + } + if err := answers.settle(core.RemoteProbeAuthenticationFailed, nil); err != nil { + t.Fatal(err) + } + if got := rememberedAnswers(store); len(got) != 0 { + t.Fatal("the refused password is still remembered") + } +} + +// What a connection learned is applied by how it ended: a typed password is remembered only after +// a login, a remembered one is forgotten when the login fails without a question cancelled, and +// one the host refused is forgotten whatever the outcome. +func TestRemoteAnswersSettleByOutcome(t *testing.T) { + ctx := remoteAnswersContext(t) + for _, test := range []struct { + name string + answers *remoteAnswers + status core.RemoteProbeStatus + err error + remembers []string + }{ + {"typed, connected", &remoteAnswers{choices: []remoteconn.AnswerChange{{Question: "q", Answer: "typed"}}}, core.RemoteProbeConnected, nil, []string{"typed"}}, + {"typed, no server build", &remoteAnswers{choices: []remoteconn.AnswerChange{{Question: "q", Answer: "typed"}}}, core.RemoteProbeUnsupportedPlatform, nil, []string{"typed"}}, + {"typed, refused", &remoteAnswers{choices: []remoteconn.AnswerChange{{Question: "q", Answer: "typed"}}}, core.RemoteProbeAuthenticationFailed, nil, []string{"old"}}, + {"typed, failed to run", &remoteAnswers{choices: []remoteconn.AnswerChange{{Question: "q", Answer: "typed"}}}, core.RemoteProbeConnected, context.DeadlineExceeded, []string{"old"}}, + {"unticked, refused", &remoteAnswers{choices: []remoteconn.AnswerChange{{Question: "q", Forget: true}}}, core.RemoteProbeAuthenticationFailed, nil, nil}, + {"sent, refused", &remoteAnswers{sent: map[string]bool{"q": true}}, core.RemoteProbeAuthenticationFailed, nil, nil}, + {"sent, refused after a cancel", &remoteAnswers{sent: map[string]bool{"q": true}, cancelled: true}, core.RemoteProbeAuthenticationFailed, nil, []string{"old"}}, + {"sent, unreachable", &remoteAnswers{sent: map[string]bool{"q": true}}, core.RemoteProbeUnreachable, nil, []string{"old"}}, + {"asked again, connected", &remoteAnswers{refused: map[string]bool{"q": true}}, core.RemoteProbeConnected, nil, nil}, + } { + t.Run(test.name, func(t *testing.T) { + store := &memorySecrets{} + if err := remoteconn.ChangeAnswers(ctx, store, "build", []remoteconn.AnswerChange{{Question: "q", Answer: "old"}}); err != nil { + t.Fatal(err) + } + answers := test.answers + answers.secrets, answers.owner = store, "build" + if err := answers.settle(test.status, test.err); err != nil { + t.Fatal(err) + } + var remembers []string + if answer, found, err := remoteconn.RememberedAnswer(ctx, store, "build", "q"); err != nil { + t.Fatal(err) + } else if found { + remembers = append(remembers, answer) + } + if !slices.Equal(remembers, test.remembers) { + t.Fatalf("remembers %q, want %q", remembers, test.remembers) + } + if answers.sent != nil || answers.refused != nil || answers.cancelled || answers.choices != nil { + t.Fatal("settling kept what the connection learned") + } + }) + } + var none *remoteAnswers + if err := none.settle(core.RemoteProbeConnected, nil); err != nil { + t.Fatal(err) + } +} diff --git a/desktop/internal/workbench/remote_browse.go b/desktop/internal/workbench/remote_browse.go index 5cc9493f4..e278d8793 100644 --- a/desktop/internal/workbench/remote_browse.go +++ b/desktop/internal/workbench/remote_browse.go @@ -133,13 +133,15 @@ func (a *App) connectRemoteTo(entry core.SavedRemoteConnection, host remoteHost, }) }) generation, kernel, root, secrets := r.generation, a.kernel, a.globalToolchainRoot(), a.remoteSecrets() + answers := a.remoteAnswersFor(entry.ID, host) a.background(nil, 0, func(context.Context) func(*App) { defer cancel() // A session a window closed with "Keep on Host" resumes (§9.2). Whichever session the // connection ends up with, the stored one is spent: resumed, it is this connection's; not // resumed, the host no longer has it. resume, keptErr := remoteconn.NewestKept(ctx, secrets, entry.ID) - result, err := a.connectRemoteHost(a.gitAuthentication(ctx), kernel, root, host, resume) + result, err := a.connectRemoteHost(a.remoteAuthentication(ctx, answers, true), kernel, root, host, resume) + settled := answers.settle(result.Status, err) if resume != nil && result.Session != nil { if forgetErr := remoteconn.ForgetKept(ctx, secrets, entry.ID, resume.Key); keptErr == nil { keptErr = forgetErr @@ -149,6 +151,7 @@ func (a *App) connectRemoteTo(entry core.SavedRemoteConnection, host remoteHost, if keptErr != nil { a.backgroundFailed("remote_kept_sessions", keptErr) } + a.remoteAnswersSettled(settled, true) r := &a.remote if !r.open || r.generation != generation || r.connect != attempt { if result.Session != nil { diff --git a/desktop/internal/workbench/remote_close.go b/desktop/internal/workbench/remote_close.go index 89558e37f..5c059bd4f 100644 --- a/desktop/internal/workbench/remote_close.go +++ b/desktop/internal/workbench/remote_close.go @@ -41,9 +41,9 @@ var ( ) // remoteSecrets is the secret store the kept host sessions are remembered in. -func (a *App) remoteSecrets() remoteconn.KeptSecrets { - if a.remoteKeptSecrets != nil { - return a.remoteKeptSecrets +func (a *App) remoteSecrets() remoteconn.Secrets { + if a.remoteSecretStore != nil { + return a.remoteSecretStore } return credentials.Default() } @@ -228,7 +228,7 @@ const ( // one that does not answer keeps it stored, since the host may have kept the session, and the next // connection forgets it if the host did not. It runs off the window thread; err is what the log // keeps. -func keepRemoteSession(ctx context.Context, kernel Kernel, secrets remoteconn.KeptSecrets, connectionID, session string, resume *core.RemoteResume) (remoteKeep, error) { +func keepRemoteSession(ctx context.Context, kernel Kernel, secrets remoteconn.Secrets, connectionID, session string, resume *core.RemoteResume) (remoteKeep, error) { stored := errRemoteNoResumeToken if resume != nil { stored = remoteconn.RememberKept(ctx, secrets, connectionID, *resume) diff --git a/desktop/internal/workbench/remote_close_test.go b/desktop/internal/workbench/remote_close_test.go index dc6feeff6..7b86a99f8 100644 --- a/desktop/internal/workbench/remote_close_test.go +++ b/desktop/internal/workbench/remote_close_test.go @@ -14,22 +14,22 @@ import ( "github.com/1lck/Lithe-IDEA/desktop/internal/remoteconn" ) -// memoryKeptSecrets is the secret store of the tests' kept host sessions; failSet fails every +// memorySecrets is the secret store of the tests' kept host sessions; failSet fails every // write. -type memoryKeptSecrets struct { +type memorySecrets struct { mu sync.Mutex items map[string]string failSet error } -func (s *memoryKeptSecrets) Get(_ context.Context, namespace, key string) (string, bool, error) { +func (s *memorySecrets) Get(_ context.Context, namespace, key string) (string, bool, error) { s.mu.Lock() defer s.mu.Unlock() secret, found := s.items[namespace+"\x00"+key] return secret, found, nil } -func (s *memoryKeptSecrets) Set(_ context.Context, namespace, key, secret string) error { +func (s *memorySecrets) Set(_ context.Context, namespace, key, secret string) error { s.mu.Lock() defer s.mu.Unlock() if s.failSet != nil { @@ -42,7 +42,7 @@ func (s *memoryKeptSecrets) Set(_ context.Context, namespace, key, secret string return nil } -func (s *memoryKeptSecrets) Delete(_ context.Context, namespace, key string) error { +func (s *memorySecrets) Delete(_ context.Context, namespace, key string) error { s.mu.Lock() defer s.mu.Unlock() delete(s.items, namespace+"\x00"+key) @@ -64,7 +64,7 @@ func keptOf(t *testing.T, h *harness) *core.RemoteResume { t.Helper() ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) defer cancel() - resume, err := remoteconn.NewestKept(ctx, h.app.remoteKeptSecrets, savedRemoteConnections(t, h)[0].ID) + resume, err := remoteconn.NewestKept(ctx, h.app.remoteSecretStore, savedRemoteConnections(t, h)[0].ID) if err != nil { t.Fatalf("read the kept sessions: %v", err) } @@ -371,7 +371,7 @@ func TestRemoteCloseEndsWhenTheSessionCannotBeKept(t *testing.T) { h, k, _, logger := remoteWorkspaceHarness(t) lang := h.app.language() values := map[string]string{"connection": remoteTestHost} - secrets := h.app.remoteKeptSecrets.(*memoryKeptSecrets) + secrets := h.app.remoteSecretStore.(*memorySecrets) secrets.failSet = errors.New("the secret store is locked") h.openRemoteTestProject(t) k.set(func(k *remoteHostKernel) { k.close.running = remoteTestPrograms }) diff --git a/desktop/internal/workbench/remote_connections_visual_test.go b/desktop/internal/workbench/remote_connections_visual_test.go index cb54173dc..4a9b17d96 100644 --- a/desktop/internal/workbench/remote_connections_visual_test.go +++ b/desktop/internal/workbench/remote_connections_visual_test.go @@ -18,8 +18,9 @@ import ( // TestVisualRemoteConnections captures the Remote Development window: the first page with nothing // saved, saved connections under their groups with the tested one's overview, its form, a new -// connection whose host Core refused under its field, OpenSSH's password question over the window, -// a refused test, the connection steps with OpenSSH's questions on the page and a failure, the +// connection whose host Core refused under its field, OpenSSH's password question over the window +// with its Remember box, a refused test, the connection steps with OpenSSH's questions on the page +// (a remembered password the host refused among them) and a failure, the // question whether to trust a folder, Motty's hosts to import, the host's folders and its running // containers, a WSL // distribution's page and a failed connection to one, a container's page and a failed connection @@ -170,10 +171,12 @@ func TestVisualRemoteConnections(t *testing.T) { shot("refused") r.selectEntry(buildBox) + // A saved connection's password question offers to remember the answer. done := make(chan struct{}) - h.app.gitAuth.queue = append(h.app.gitAuth.queue, core.GitAuthChallenge{ - RequestID: "visual", Prompt: "dev@build.example's password: ", Secret: true, Attempt: 1, Remote: true, Done: done, - }) + h.app.gitAuth.queue = append(h.app.gitAuth.queue, gitAuthQuestion{GitAuthChallenge: core.GitAuthChallenge{ + RequestID: "visual", Prompt: "dev@build.example's password: ", Secret: true, Attempt: 1, Remote: true, + Kind: core.RemoteQuestionPassword, Done: done, + }, answers: &remoteAnswers{owner: buildBox}, question: "visual"}) shot("password") h.app.gitAuth.queue = nil close(done) @@ -202,16 +205,19 @@ func TestVisualRemoteConnections(t *testing.T) { steps := newRemoteSteps(*r.entry(buildBox), remoteHost{ssh: r.entry(buildBox).Connection}, "", h.app.now()) r.steps = steps asked := make(chan struct{}) - h.app.gitAuth.queue = []core.GitAuthChallenge{{ + h.app.gitAuth.queue = []gitAuthQuestion{{GitAuthChallenge: core.GitAuthChallenge{ RequestID: "visual-key", Prompt: "Are you sure you want to continue connecting (yes/no/[fingerprint])? ", Remote: true, Kind: core.RemoteQuestionHostKey, KeyType: "ED25519", Fingerprint: "SHA256:7Yb0QaBf3c1uN0e9kVwq2XrJmZpT4sLhG8dEoUiAy6c", Attempt: 1, Done: asked, - }} + }}} shot("steps-host-key") steps.advance(h.app.now(), remoteStepAuthenticate) - h.app.gitAuth.queue = []core.GitAuthChallenge{{ - RequestID: "visual-password", Prompt: "dev@build.example's password: ", Secret: true, Remote: true, Attempt: 1, Done: asked, - }} + // The host refused the answer remembered last time, so the question is asked again with + // Remember still ticked. + h.app.gitAuth.queue = []gitAuthQuestion{{GitAuthChallenge: core.GitAuthChallenge{ + RequestID: "visual-password", Prompt: "dev@build.example's password: ", Secret: true, Remote: true, Attempt: 2, + Kind: core.RemoteQuestionPassword, Done: asked, + }, answers: &remoteAnswers{owner: buildBox}, question: "visual-password", remembered: true, refused: true}} shot("steps-password") h.app.gitAuth.queue = nil close(asked) diff --git a/desktop/internal/workbench/remote_detail_view.go b/desktop/internal/workbench/remote_detail_view.go index af7616828..47a238223 100644 --- a/desktop/internal/workbench/remote_detail_view.go +++ b/desktop/internal/workbench/remote_detail_view.go @@ -224,6 +224,9 @@ func (a *App) remoteMoreMenu(c ui.C, language i18n.Language, entry core.SavedRem if menu.Item(i18n.Shared(language, "desktop.remote.copyAsNew")).Icon(icons.Copy).Disabled(!r.editable()).Clicked() { c.After(a.copyRemoteAsNew) } + if menu.Item(i18n.Shared(language, "desktop.remote.forgetAnswers")).Icon(icons.Eraser).Clicked() { + c.After(func() { a.forgetRemoteAnswers(entry) }) + } menu.Separator() remove := menu.Item(i18n.SharedFormat(language, "desktop.remote.deleteNamed", map[string]string{"name": entry.Name})). Icon(icons.Trash2).Destructive().Disabled(!r.editable()) diff --git a/desktop/internal/workbench/remote_steps.go b/desktop/internal/workbench/remote_steps.go index 4d328d21c..2818a43dd 100644 --- a/desktop/internal/workbench/remote_steps.go +++ b/desktop/internal/workbench/remote_steps.go @@ -143,7 +143,7 @@ func (s *remoteSteps) fail(now time.Time, outcome *remoteProbeOutcome, language } // remoteQuestion is the question OpenSSH asks now, nil when none is asked. -func (a *App) remoteQuestion() *core.GitAuthChallenge { +func (a *App) remoteQuestion() *gitAuthQuestion { if g := &a.gitAuth; len(g.queue) > 0 && g.queue[0].Remote { return &g.queue[0] } @@ -201,7 +201,7 @@ func (a *App) remoteStepsView(c ui.C, language i18n.Language, s *remoteSteps) { // remoteStepRow declares a step: done, running, failed or still to come, and the question it // asks. -func (a *App) remoteStepRow(c ui.C, language i18n.Language, s *remoteSteps, step, reached remoteStep, question *core.GitAuthChallenge) { +func (a *App) remoteStepRow(c ui.C, language i18n.Language, s *remoteSteps, step, reached remoteStep, question *gitAuthQuestion) { small := a.theme.Metrics.FontSizeS done := step < reached current := step == reached @@ -259,11 +259,9 @@ func remoteDuration(language i18n.Language, took time.Duration) string { // remoteQuestionCard declares OpenSSH's question under the step that asks it: the host's key to // trust, or a field for the answer. -func (a *App) remoteQuestionCard(c ui.C, language i18n.Language, s *remoteSteps, head core.GitAuthChallenge) { +func (a *App) remoteQuestionCard(c ui.C, language i18n.Language, s *remoteSteps, head gitAuthQuestion) { g := &a.gitAuth - if g.fieldFor != head.RequestID { - g.field, g.fieldFor = ui.Field{}, head.RequestID - } + g.answering(head) small := a.theme.Metrics.FontSizeS id := head.RequestID answer := func(text string, confirm bool) { @@ -317,14 +315,13 @@ func (a *App) remoteQuestionCard(c ui.C, language i18n.Language, s *remoteSteps, if prompt := strings.TrimSpace(head.Prompt); prompt != "" { ui.Paragraph(c, prompt, 3).Mono().FontSize(small).Color(a.colors.Subtle) } + a.gitAuthAgain(c, language, head, small) field := ui.TextField(c.Part(head.RequestID), &g.field, i18n.Shared(language, "desktop.remote.question.answer"), "").FillWidth().AutoFocus() if head.Secret { field = field.Secure() } submitted := field.Submitted() - if head.Attempt > 1 { - ui.Text(c, i18n.Shared(language, "desktop.remoteAuth.refused")).FontSize(small).Color(a.theme.Danger) - } + a.gitAuthKeeping(c, language, head, small) ui.Row(c.Part("buttons")).FillWidth().Gap(8).Children(func() { ui.Spacer(c) if ui.Button(c.Part("cancel"), i18n.Shared(language, "desktop.remote.cancel")).Outline().Clicked() { diff --git a/desktop/internal/workbench/remote_test.go b/desktop/internal/workbench/remote_test.go index bd2dcaf4b..e9de71650 100644 --- a/desktop/internal/workbench/remote_test.go +++ b/desktop/internal/workbench/remote_test.go @@ -485,8 +485,8 @@ exec /bin/sh -c "$last" // Testing a connection asks OpenSSH's password question in the SSH authentication dialog over // the window, and shows what the host reported once it is answered; cancelling the question -// shows the server's refusal with OpenSSH's output. Neither the password, the host nor the user -// is logged. +// shows the server's refusal with OpenSSH's output. A connection that is not saved offers to +// remember nothing. Neither the password, the host nor the user is logged. func TestRemoteTestAsksInTheWindowAndReportsTheHost(t *testing.T) { standInSSH(t) h, logger := remoteHarness(t) @@ -505,6 +505,9 @@ func TestRemoteTestAsksInTheWindowAndReportsTheHost(t *testing.T) { if h.shows(i18n.Shared(lang, "desktop.gitAuth.title")) { t.Fatal("the remote question is titled as Git's") } + if h.shows(i18n.Shared(lang, "desktop.remoteAuth.rememberPassword")) { + t.Fatal("a connection that is not saved offers to remember its password") + } if got := h.focusedName(); got != i18n.Shared(lang, "desktop.gitAuth.answer") { t.Fatalf("focused %q, want the answer field", got) } diff --git a/desktop/internal/workbench/remote_workspace.go b/desktop/internal/workbench/remote_workspace.go index e2a874ebf..e7dfcf780 100644 --- a/desktop/internal/workbench/remote_workspace.go +++ b/desktop/internal/workbench/remote_workspace.go @@ -458,16 +458,18 @@ func (a *App) reconnectRemote(p *project, userStarted bool) { r.stopRemoteTimer() r.link, r.failure = remoteReconnecting, nil ctx, cancel := context.WithTimeout(a.operationContext(p.ctx), remoteProbeTimeout) - if userStarted { - ctx = a.gitAuthentication(ctx) - } + // An automatic attempt sends only what the connection remembers (remote_answers.go). + answers := a.remoteAnswersFor(r.connectionID, r.host) + ctx = a.remoteAuthentication(ctx, answers, userStarted) attempt := &remoteProbe{cancel: cancel} r.reconnecting = attempt kernel, root, host, resume := a.kernel, a.globalToolchainRoot(), r.host, r.resume a.background(nil, 0, func(context.Context) func(*App) { defer cancel() result, err := a.connectRemoteHost(ctx, kernel, root, host, resume) + settled := answers.settle(result.Status, err) return func(a *App) { + a.remoteAnswersSettled(settled, userStarted) if a.project != p || r.closed || r.reconnecting != attempt { if result.Session != nil { a.releaseRemoteSession(result.Session.ID) diff --git a/desktop/internal/workbench/window_sessions.go b/desktop/internal/workbench/window_sessions.go index 90e05dfad..5fc88944b 100644 --- a/desktop/internal/workbench/window_sessions.go +++ b/desktop/internal/workbench/window_sessions.go @@ -257,7 +257,7 @@ func (s *windowSessions) openTab(path string) { func (s *windowSessions) openRemoteTab(from *App, target remoteTarget) { a := New(s.options) a.remoteBundle, a.remoteAnchor, a.remoteAfter = from.remoteBundle, from.remoteAnchor, from.remoteAfter - a.remoteKeptSecrets = from.remoteKeptSecrets + a.remoteSecretStore = from.remoteSecretStore s.list = append(s.list, a) s.activate(a) a.reloadPluginLanguages() diff --git a/docs/assets/remote-connections/README.md b/docs/assets/remote-connections/README.md index 338454695..370877745 100644 --- a/docs/assets/remote-connections/README.md +++ b/docs/assets/remote-connections/README.md @@ -32,9 +32,9 @@ - 失败:红色框,失败原因和该检查什么(例如身份验证失败时提示检查用户名、或改用“私钥文件”);OpenSSH 的原始输出默认展开在框下方,右侧“收起”。 - **连接步骤:** 依次为读取配置、连接主机、身份验证、检查平台、安装服务端、启动会话: - OpenSSH 的主机密钥询问显示在“连接主机”下方,带密钥类型和指纹,按钮为“拒绝”和“信任并继续”; - - 密码询问显示在“身份验证”下方; + - 密码询问显示在“身份验证”下方。截图是主机拒绝了记住的密码之后:红字提示“主机没有接受记住的回答,请重新输入”,“记住密码”保持勾选,下方说明何时保存、何时自动填入; - 失败时标出失败的步骤并展开诊断。 -- **SSH 密码询问(弹窗):** 窗口上方弹出“SSH 身份验证”,提示原样显示。 +- **SSH 密码询问(弹窗):** 窗口上方弹出“SSH 身份验证”,提示原样显示。已保存的连接在输入框下有“记住密码”勾选框(口令为“记住口令”);未勾选时说明回答只交给这次连接、Lithe 不保存。未保存的连接、验证码和主机指纹询问没有这个勾选框。 - **选文件夹:** 左侧连接列表保留,面包屑显示连接名称。右侧: - 顶部:系统图标、“选择 … 上的文件夹”、连接状态、地址和系统,右侧“断开”; - 路径输入框和“前往”,下方是“常用”位置和可点击的路径面包屑; diff --git a/docs/assets/remote-connections/remote-connections-password-dark-zh-CN.png b/docs/assets/remote-connections/remote-connections-password-dark-zh-CN.png index 4b7f927fc..fac6343a9 100644 Binary files a/docs/assets/remote-connections/remote-connections-password-dark-zh-CN.png and b/docs/assets/remote-connections/remote-connections-password-dark-zh-CN.png differ diff --git a/docs/assets/remote-connections/remote-connections-password-light-en-US.png b/docs/assets/remote-connections/remote-connections-password-light-en-US.png index 08cf298f7..611a2714b 100644 Binary files a/docs/assets/remote-connections/remote-connections-password-light-en-US.png and b/docs/assets/remote-connections/remote-connections-password-light-en-US.png differ diff --git a/docs/assets/remote-connections/remote-connections-steps-password-dark-zh-CN.png b/docs/assets/remote-connections/remote-connections-steps-password-dark-zh-CN.png index 5e9cc5f24..aeee99c19 100644 Binary files a/docs/assets/remote-connections/remote-connections-steps-password-dark-zh-CN.png and b/docs/assets/remote-connections/remote-connections-steps-password-dark-zh-CN.png differ diff --git a/docs/assets/remote-connections/remote-connections-steps-password-light-en-US.png b/docs/assets/remote-connections/remote-connections-steps-password-light-en-US.png index 74858a3ad..219b2bfb3 100644 Binary files a/docs/assets/remote-connections/remote-connections-steps-password-light-en-US.png and b/docs/assets/remote-connections/remote-connections-steps-password-light-en-US.png differ diff --git a/docs/ci-builds.md b/docs/ci-builds.md index 2c31c9b6d..0410734cc 100644 --- a/docs/ci-builds.md +++ b/docs/ci-builds.md @@ -8,13 +8,13 @@ CI 构建缓存、架构并行、测试产物和 artifact 保留策略见 | 工作流 | 触发 | 内容 | | --- | --- | --- | -| **Desktop CI**(`desktop-ci.yml`) | PR(Draft 只跑 Linux 作业,`ready_for_review` 时补跑完整矩阵)、推送到 `main`、手动运行 | `pins` 校验固定版本;`linux`(Format and script tests)运行 gofmt、ShellCheck、本地化校验、安装资源路径检查和脚本测试;`linux-test` 通过 `scripts/desktop/check.sh` 运行 Linux 的 vet 和测试;`remote-server`(Remote server)调用可复用工作流 `desktop-remote-server.yml`:其中的 Remote server artifacts 任务编译两种架构的 Linux musl 远端服务,检查静态链接、ELF 架构、清单与 SHA-256,在 x86_64 runner 上运行 x86_64 版的冒烟测试,上传产物 `remote-server-linux-musl` 并把体积写进任务摘要,Remote server on arm64 任务在 `ubuntu-24.04-arm` 上下载同一份产物,重新校验并运行 aarch64 版的冒烟测试,两种架构都在原生硬件上运行,不用模拟器;`macos`(`macos-26`)、`windows`(`windows-2022`)同样运行 vet 和测试,只在非 Draft 时执行 | +| **Desktop CI**(`desktop-ci.yml`) | PR(Draft 只跑 Linux 作业,`ready_for_review` 时补跑完整矩阵)、推送到 `main`、手动运行 | `pins` 校验固定版本;`linux`(Format and script tests)运行 gofmt、ShellCheck、本地化校验、安装资源路径检查和脚本测试;`linux-test` 通过 `scripts/desktop/check.sh` 运行 Linux 的 vet 和测试;`remote-server`(Remote server)调用可复用工作流 `desktop-remote-server.yml`,分两步:Build for linux amd64 and arm64 任务在一台 x86_64 runner 上编译两种架构的 Linux musl 远端服务,只检查静态链接、ELF 架构、清单与 SHA-256(不运行),上传产物 `remote-server-linux-musl` 并把体积写进任务摘要;随后 Test on linux amd64(`ubuntu-24.04`)和 Test on linux arm64(`ubuntu-24.04-arm`)两个任务并行下载同一份产物,重新校验并各自运行本架构的冒烟测试,两种架构都在原生硬件上运行,不用模拟器;`macos`(`macos-26`)、`windows`(`windows-2022`)同样运行 vet 和测试,只在非 Draft 时执行 | | **Desktop Release**(`desktop-release.yml`) | 推送 `desktop-v*.*.*` 标签,或手动运行并填写版本 | 先调用 `desktop-remote-server.yml` 编译并在两种架构上冒烟测试远端服务,再打包并校验 macOS、Windows、Linux 产物(每个包都嵌入这一份远端服务),核对校验和,然后创建或更新 GitHub prerelease,再签名发布正式版更新源。手动版本必须与 `desktop/viva.toml` 中的版本一致 | | **Desktop AutoBuild**(`desktop-autobuild.yml`) | 每天 UTC 10:00 定时,或手动运行 | 与 Release 一样先调用 `desktop-remote-server.yml`,再构建 macOS arm64 与 x64、Windows x64、Linux x64 和 arm64,发布到滚动预发布 `desktop-AutoBuild`。同一提交已经发布时,定时运行不会重复构建 | - Draft PR 只运行 Linux 检查:macOS 和 Windows 作业带有 `draft == false` 条件。标记为 ready 后,才运行完整的 Desktop CI。 -- `Desktop CI gate` 汇总固定版本、Linux 格式与脚本、Linux 测试、远端服务(可复用工作流里的 x86_64 与 arm64 两个任务都成功,`remote-server` 才算成功)、macOS 测试和 Windows 测试;普通 PR 必须全部成功,Draft 只允许跳过 macOS 和 Windows。更换已有 PR 的目标分支后,保留 Draft 状态;需要评审时标记为 ready 以针对新基线重新运行完整检查。单纯修改标题或正文不触发平台 runner。 -- Desktop CI 通过 `scripts/desktop/check.sh` 执行 Go 检查,Rust 内核由 `scripts/desktop/build-desktop-core.sh` 按 `PINNED_CORE_REVISION` 固定的 Lithe-core-rust 修订构建。 Windows 的工作台用例按顶层测试名分三组串行运行,普通和 `dev` 构建各覆盖全部用例。每组仍遵守 Go 默认的 10 分钟上限。 +- `Desktop CI gate` 汇总固定版本、Linux 格式与脚本、Linux 测试、远端服务(可复用工作流里的构建任务和 amd64、arm64 两个测试任务都成功,`remote-server` 才算成功)、macOS 测试和 Windows 测试;普通 PR 必须全部成功,Draft 只允许跳过 macOS 和 Windows。更换已有 PR 的目标分支后,保留 Draft 状态;需要评审时标记为 ready 以针对新基线重新运行完整检查。单纯修改标题或正文不触发平台 runner。 +- Desktop CI 通过 `scripts/desktop/check.sh` 执行 Go 检查:gofmt,带与不带 `dev` 标签各 vet 一次全部包;测试时 `settingswindow`、`pluginview`、`workbench` 三个界面包只在 `dev` 标签下跑一次,其余包不带标签跑,`buildinfo` 两种标签都跑。对这三个包,`dev` 标签只换掉两个文件:Viva 的属性检查只会多报错误;`buildinfo.Development` 只影响 Dock 角标(只在真实窗口里设置)和已安装的更新渠道(测试构建不带打包信息,两种标签下都为空)。所以不带标签再跑一遍检查不到更多问题,只会让 macOS 和 Windows 多花约 8 分钟。Windows 的 `workbench` 用例按顶层测试名分三组串行运行,三组合起来覆盖全部用例,每组仍遵守 Go 默认的 10 分钟上限。Rust 内核由 `scripts/desktop/build-desktop-core.sh` 按 `PINNED_CORE_REVISION` 固定的 Lithe-core-rust 修订构建。 - Linux 测试作业也运行 `TestVisualLSPActions`,覆盖中英文与明暗主题的代码操作、签名帮助和内联提示失败重试。全量测试失败时仍采集截图。结果作为 `lsp-editor-visual-<系统>-<架构>` artifact 保留 14 天。 - Desktop Release 的打包脚本是 `scripts/ci/desktop-release/package-release.sh`,AutoBuild 的打包和发布脚本位于 `scripts/ci/desktop-autobuild/`。 - 两条发布入口共用 `scripts/desktop/package-desktop.sh`,通过 Viva 的 `--cgo` 选项保留 Rust Core 原生桥接;`desktop-go.sh` 提供目标编译器、静态库及头文件。Linux 发布包由 Ubuntu 22.04 构建,其系统库兼容性需要单独验证,不能按 Viva 的默认纯 Go 包假设没有 glibc 依赖。 @@ -162,13 +162,13 @@ built-from 检出,换检出时只清理工作区成员。全部目标编译成 放入 `<目标>/lithe-remote-server` 和 `remote-server-manifest.json`(Core 提交、`coreWorktree`、`coreSource`、服务版本、rustc, 以及每个文件的体积和 SHA-256)。`scripts/desktop/verify/verify-remote-server-artifacts.mjs` 读取这个目录:检查清单字段、 文件哈希、ELF 架构和静态链接(没有解释器、没有动态库依赖),在同架构的 Linux 上再跑 `--identity`、`--version` 和一次 -`server.hello`;不同架构的文件不交给模拟器运行,只报告跳过。`--require-smoke <目标>` 要求该目标的冒烟测试在本机跑通,可重复, -`all` 表示全部目标;`--require-pinned` 要求清单来自固定提交且工作区干净。体积只记录在报告和 +`server.hello`;不同架构的文件不交给模拟器运行,只报告跳过。`--smoke <目标>` 只对该目标做冒烟测试,并要求它在本机跑通, +可重复,其余目标只做文件检查、报告“not run here”;`all` 表示全部目标,`none` 表示一个都不运行;不传时对本机能运行的目标都做冒烟测试。`--require-pinned` 要求清单来自固定提交且工作区干净。体积只记录在报告和 CI 任务摘要里,不设上限(#2231 的 D9)。随 `.artifacts/desktop/` 复制到另一个工作树时,除上一段的前提外,还要满足 Rust 工具链和已安装目标相同、源工作树不在编译,并在使用前运行一次验证脚本确认清单哈希仍然一致;否则删掉 `remote-server/`, 重新运行构建脚本。这个目录本身是构建状态:它不作为独立文件进入安装包,打包时按上文嵌入客户端二进制;开发运行只读取它, -不写入。Desktop CI、Release 和 AutoBuild 都调用 `desktop-remote-server.yml` 构建一次,Release 与 AutoBuild 的每个打包任务 -下载这一份产物(artifact 不保留可执行位,下载后恢复 0755),通过 `LITHE_REMOTE_SERVER_STAGE` 交给 `package-desktop.sh`, +不写入。Desktop CI、Release 和 AutoBuild 都先调用 `desktop-remote-server.yml` 构建一次并在两种架构上测试,之后才开始编译应用: +Release 与 AutoBuild 的每个打包任务下载这一份产物(artifact 不保留可执行位,下载后恢复 0755),通过 `LITHE_REMOTE_SERVER_STAGE` 交给 `package-desktop.sh`, 所以同一次运行的所有安装包嵌入相同的、已在两种架构上冒烟测试过的字节。 共享翻译源文件位于 `shared/i18n/`,桌面端生成文件是 Git 跟踪的 `desktop/internal/i18n/shared.generated.go`。每个工作树通过 Git 获取源文件和生成文件,然后运行 `node scripts/i18n/generate-i18n.mjs --check` 校验。修改源翻译后运行不带 `--check` 的同一命令,在当前工作树重新生成。资源身份由当前语言清单、词条和翻译共同决定,不需要下载,也没有独立的工具链或可复用 identity stamp。不要从其他工作树复制生成文件。生成文件随源码编译,不写入安装资源,也不改变签名和增量更新基线。维护步骤见 [共享翻译说明](../shared/i18n/README.md)。 diff --git a/scripts/desktop/check.sh b/scripts/desktop/check.sh index 46a5191d9..104ea4e76 100755 --- a/scripts/desktop/check.sh +++ b/scripts/desktop/check.sh @@ -8,6 +8,15 @@ ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd -P)" DESKTOP="$ROOT_DIR/desktop" GO="$ROOT_DIR/scripts/desktop/desktop-go.sh" +# The UI packages are tested once, with the dev tag. Across everything they build, the tag swaps +# only two files. One is Viva's attribute checks, which can only add failures. The other sets +# buildinfo.Development, which the UI reads for the Dock badge, set only in a running window, and +# for the installed update channel, which a test build lacks either way: only packaging records +# one. A run without the tag would repeat the same tests (workbench alone takes about eight +# minutes on macOS and Windows) and check nothing more. buildinfo has tests for both values of +# the flag, so it runs both times. +DEV_TESTED=(./internal/settingswindow ./internal/pluginview ./internal/workbench) + unformatted="$(cd "$DESKTOP" && gofmt -l .)" if [[ -n "$unformatted" ]]; then printf 'gofmt would change:\n%s\n' "$unformatted" >&2 @@ -16,28 +25,26 @@ fi "$GO" vet ./... "$GO" vet -tags dev ./... -# A full Windows workbench run measured 588 seconds against Go's 10-minute -# package deadline. Split its top-level tests into disjoint groups, keeping the -# default deadline for every group and the same coverage for both build tags. -test_workbench_groups() { - "$GO" test "$@" -run '^Test[A-C]' ./internal/workbench - "$GO" test "$@" -run '^Test[D-P]' ./internal/workbench - "$GO" test "$@" -skip '^Test[A-P]' ./internal/workbench -} +all_packages="$("$GO" list ./...)" +dev_packages="$("$GO" list "${DEV_TESTED[@]}")" +untagged=() +while IFS= read -r package; do + untagged+=("$package") +done < <(printf '%s\n' "$all_packages" | grep -vxF -f <(printf '%s\n' "$dev_packages")) +if (( ${#untagged[@]} != $(wc -l <<<"$all_packages") - ${#DEV_TESTED[@]} )); then + printf 'Expected every package except %s in the untagged test run.\n' "${DEV_TESTED[*]}" >&2 + exit 1 +fi + +"$GO" test "${untagged[@]}" if [[ "$(go env GOOS)" == windows ]]; then - listed_packages="$("$GO" list ./...)" - packages=() - while IFS= read -r package; do - if [[ "$package" != */internal/workbench ]]; then - packages+=("$package") - fi - done <<< "$listed_packages" - "$GO" test "${packages[@]}" - test_workbench_groups + # A full Windows workbench run measured 588 seconds against Go's 10-minute package + # deadline. Split its top-level tests into disjoint groups, each under the default deadline. "$GO" test -tags dev ./internal/buildinfo ./internal/settingswindow ./internal/pluginview - test_workbench_groups -tags dev + "$GO" test -tags dev -run '^Test[A-C]' ./internal/workbench + "$GO" test -tags dev -run '^Test[D-P]' ./internal/workbench + "$GO" test -tags dev -skip '^Test[A-P]' ./internal/workbench else - "$GO" test ./... - "$GO" test -tags dev ./internal/buildinfo ./internal/settingswindow ./internal/pluginview ./internal/workbench + "$GO" test -tags dev ./internal/buildinfo "${DEV_TESTED[@]}" fi diff --git a/scripts/desktop/verify/verify-remote-server-artifacts.mjs b/scripts/desktop/verify/verify-remote-server-artifacts.mjs index fad1a2744..ca9bfe7a0 100644 --- a/scripts/desktop/verify/verify-remote-server-artifacts.mjs +++ b/scripts/desktop/verify/verify-remote-server-artifacts.mjs @@ -3,7 +3,7 @@ // staged, and reports their sizes. // // Usage: node scripts/desktop/verify/verify-remote-server-artifacts.mjs -// [--stage