4 Commits

Author SHA1 Message Date
Serendipity b053272825 fix: 安全漏洞修复 — CLI密码泄露 + margin上限 + 路径检查 + CSP/限速
CRITICAL:
- CLI --password 未提供时自动从 QRGEN_WIFI_PASSWORD 环境变量读取
  避免密码出现在 ps aux / /proc/pid/cmdline 进程列表中

HIGH:
- unsafe from_utf8_unchecked SAFETY 注释增强, 详细解释为何有效
- CLI --margin 添加 value_parser range(0..=100), 防止 u8=255 导致内存爆炸
- Web CORS permissive 添加注释说明公开 API 设计理由
- GUI FS 权限收紧: 写权限从 /c/Users/33644/** 限制为 Downloads/Documents/Desktop/AppData

MEDIUM:
- 新增 QrError::InvalidEcLevel(String), 不再复用 InvalidVersion(0)
- --logo/--batch/--output_dir 均添加 check_path() 路径遍历检查
- Web 添加 tower::limit::ConcurrencyLimitLayer(10) 并发限制防 CPU 耗尽
- decode_image 添加 4096x4096 图片尺寸上限防解压炸弹

LOW:
- Web 添加 Content-Security-Policy 响应头
2026-06-21 16:09:08 +08:00
Serendipity 11fbe20102 feat: GUI 端新增解码功能 — 选择图片解码 QR 码
- 新增 decode_qr Tauri command(接收图片字节,返回解码文本)
- ExportPanel 新增「选择图片解码」按钮 + 解码结果展示
- fs:allow-read-file 权限,支持 /c/Users/33644 和 C:\Users\33644\AppData\Local\Temp 路径
2026-06-19 20:39:07 +08:00
Serendipity 05b1714628 fix: QR 扫描失败 + GUI 导出失败 — PNG margin + separator + fs 插件
🔴 QR 扫描失败根因 (2项):
- render/png: saturating_sub 导致 margin 区域映射到 finder 黑角,
  quiet zone 全黑,扫描器无法定位 QR
- matrix/patterns: 缺少右上 finder 左侧 + 左下 finder 顶部
  隔离带预留,数据模块破坏 finder 检测比率(1:1:3:1:1)

🔴 GUI 导出失败 (2项):
- gui/Cargo.toml + gui/lib.rs: 注册 tauri-plugin-fs 后端插件
  (前端 writeFile 调用缺少 Rust handler)
- capabilities: fs:allow-write-file + $HOME/** 路径 scope
  (ACL 默认不给 fs 写权限,需显式声明)

🔧 其他:
- ExportPanel: 导出失败显示红色错误信息(替代静默吞错)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-18 11:21:27 +08:00
Serendipity 1e9c94eff9 fix: 全面代码审查修复 — 安全/类型/持久化/代码质量 (28项)
🔴 CRITICAL (1):
- tauri.conf.json: CSP 从 null 改为最小权限策略

🟠 HIGH (6):
- 新建 capabilities/default.json: Tauri v2 权限约束(store/dialog/clipboard)
- cli: 路径遍历防护 — 拒绝含 ParentDir 组件的输出路径
- HistoryList: 删除/清空同步持久化到 store,历史点击用 formData 回填
- ExportPanel: 移除 console.warn,getCurrentText any→QrState
- useQrEncode: WiFi 密码在历史中脱敏显示(P:***),Store 实例缓存

🟡 MEDIUM (10):
- mode.rs: Kanji fallback 从 UTF-8 字节改为 13-bit 零值占位(段内模式一致)
- mode.rs: Shift JIS 第二字节跳过 0x7F 空洞,修正行内索引
- mode.rs: encode_numeric/alphanumeric 添加 debug_assert! 前置条件
- mask.rs: best_matrix.unwrap()→expect() 附错误信息
- version.rs: ec_info 仅返回 count>0 的 BlockInfo,EcInfo/BlockInfo 加 Debug+Clone
- types/index.ts: HistoryEntry.mode string→ModeType,新增 formData 字段
- qrContext.tsx: 使用缓存 Store 加载历史

🟢 LOW (11):
- cargo fmt 全部文件
- svg.rs: String::new()→with_capacity() 预分配
- patterns.rs: encode_format_info 拆分为两行提高可读性
- png.rs: 提取 fill_module() 辅助函数降低嵌套
- ErrorBoundary: 添加 componentDidCatch 错误日志入口
- QrPreview: dangerouslySetInnerHTML→<img>+data URL(安全),loading 状态指示
- galois.rs/version.rs: 5 处 #[allow(clippy::indexing_slicing)]+安全文档
- 新建 utils/qrText.ts: 集中管理 6 种模式的文本构造,消除 ExportPanel/mode 间重复

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-17 14:10:13 +08:00