Skip to content

fix: 按 review 分批修复数据安全、健壮性、文档与工程化问题 - #4

Merged
JackyZhang8 merged 6 commits into
mainfrom
devin/1792831218-review-fixes
Oct 24, 2026
Merged

JackyZhang8 merged 6 commits into
mainfrom
devin/1792831218-review-fixes

Conversation

@devin-ai-integration

Copy link
Copy Markdown
Contributor

Summary

按 review 缺陷表分 4 批修复(每批一个 commit,外加一个启动轮询回归修复)。

第 1 批 数据安全

  • RestoreBackup(path, crypto, key):未解锁直接拒绝;ZIP 先解压到临时目录,跳过 locknote.db* / data_key_verifier / restore-snapshots;用当前 data key 解密校验所有 .enc,校验失败则拒绝恢复(防止跨 vault 恢复导致正文无法解密);写入前生成 restore-snapshots/<ts> 快照,失败回滚;限制单文件、总大小和条目数量。
  • HasMasterPassword() (bool, error),SaveMasterPassword 拆为 InsertMasterPassword / UpdateMasterPassword,不再 INSERT OR REPLACE 覆盖已有主密钥;IsFirstRun() (bool, error)。
  • SetupPassword:后端校验 displayKey;先写 verifier(原子写),再插入主密钥,插入失败时删除 verifier。
  • 新增 internal/fsutil.WriteFileAtomic(同目录临时文件 → fsync → rename → 父目录 fsync)。
  • 前端 registerEditorFlush / flushEditor:切换笔记、Cmd+L 锁定、窗口失焦/隐藏、关闭前都会 flush 防抖保存;Wails OnBeforeClose → app:before-close → ConfirmClose()(3s 超时兜底)。
  • MainLayout 加载笔记时用 cancelled 标记,避免旧请求覆盖新选中的笔记。

第 2 批 健壮性

  • coreOrErr():core 未就绪时 API 返回错误,不再 nil panic。
  • 迁移检查所有 Exec 错误,引入 PRAGMA user_version;busy_timeout=5000 + WAL。
  • mobileCallRead 改用 RLock;Markdown 链接:# 内部跳转,http/https/mailto 用 BrowserOpenURL 打开,其它 scheme 阻止;图片上限 50 MiB;导出文件名清理;Argon2 派生不再持有 c.mu。
  • notes 解密逻辑抽取公共 helper,用 EncryptedTitle == nil 判断 fallback。

第 3 批 性能与文档

  • notes.Service 内容缓存(按 ID、更新时间、密文路径校验),锁定、恢复、导入、历史恢复后清空。
  • README(中英)新增 Security Model:说明哪些数据未加密(标签名、笔记本名、附件文件名、智能视图、密码提示)、备份范围,以及只能恢复同一 vault 的备份;BackupView 提示和硬编码中文迁移到三语 i18n。

第 4 批 工程化

  • 新增 ci.yml(Go vet/test、tsc、前端测试),release-v2.yml 依赖它并使用 go-version-file: go.mod、wails@v2.12.0;删除重复的 release.yml。
  • frontend/package.json 版本统一为 1.0.9 并加 test script;删除未使用的 EncryptFile/DecryptFile;移除被跟踪的 .idea 和 build/bin;补 crypto/core/backup/database/fsutil/attachments 及前端测试。

本 PR 不包含:元数据加密(只写文档说明)、恢复密钥派生算法变更(只做格式校验)、组件拆分、alert 改 toast、macOS Bundle ID 修改。

验证:go vet ./internal/... .、go test ./internal/... .、go vet ./mobile、npx tsc --noEmit、TZ=Asia/Shanghai npm test(116/116)。没有在桌面端手动跑过 UI。

Link to Devin session: https://app.devin.ai/sessions/d9ef026cb9244270a2d90f54f6d763a4
Open in Devin Desktop: https://app.devin.ai/desktop/session/d9ef026cb9244270a2d90f54f6d763a4?variant=devin
Requested by: @JackyZhang8

JackyZhang8 and others added 5 commits October 24, 2026 08:45
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@JackyZhang8
JackyZhang8 merged commit 898ae91 into main Oct 24, 2026
1 check passed
@JackyZhang8
JackyZhang8 deleted the devin/1792831218-review-fixes branch November 5, 2026 04:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant