Skip to content

[Code Review] GeneralUpdate.Core 全量代码审查报告 — 17/17 项已修复 #517

Description

@JusterZhu

审查范围

对 GeneralUpdate.Core 全模块(Bootstrap / Pipeline / Differential / IPC / Security / Strategy / FileSystem / Hooks / Silent / GracefulExit)进行系统性代码审查。

修复状态:✅ 全部完成(17/17)

修复 PR: #516


🔴 Critical(1/1 已修复)

C1 — GetTempDirectory() 路径遍历风险Pipeline/DiffPipeline.cs:575
修复: 改用 StartsWith+Substring 替代 string.Replace 做路径计算。


🟠 High(4/4 已修复)

H1 — BsdiffDiffer 大文件 OOMPipeline/DiffPipelineOptions.cs, DiffPipeline.cs
修复: 新增 MaxInputFileSize 属性,调用 differ 前校验文件大小,超限时抛 InvalidOperationException。默认 0 表示不限制。

H2 — Process.Start 返回值未检查 — 5 个 Strategy 文件
修复: 所有 Process.Start() 均检查返回值,失败时抛异常。

H3 — UnixPermissionHooks 参数注入Hooks/IUpdateHooks.cs:52
修复: .NET 6+ 用 ArgumentList;netstandard2.0 保留引号包裹缓解方案。

H4 — SafeOnBeforeUpdateAsync 异常时行为错误Strategy/ClientStrategy.cs:1015-1026
修复: 异常时返回 false(中止更新)而非 true(放行更新)。


🟡 Medium(7/7 已修复)

M2 — HttpClientProvider 无限超时Network/HttpClientProvider.cs:41
修复: 设置 5 分钟安全网上限,替代 InfiniteTimeSpan

M3 — StorageManager 目录跳过使用子串匹配FileSystem/StorageManager.cs
修复: GetAllFilesCopyDirectory 中的 Contains 改为 StartsWith 前缀匹配。

M4 — DateTime.Now 替换FileSystem/StorageManager.cs
修复: GetTempDirectoryGetBackupDirectoryName 均改为 DateTime.UtcNow

M6 — SilentPollOrchestrator 后台异常静默Silent/SilentPollOrchestrator.cs:84-88,132-137
修复: 轮询异常和后台线程异常通过 EventManager 分发 ExceptionEventArgs

M7 — DefaultDirtyMatcher 缺少 null 校验Differential/DefaultDirtyMatcher.cs:34
修复: 添加 ArgumentNullException 守卫。

M8 — GracefulExit 无窗口进程文档GracefulExit.cs
修复: 补充 CloseMainWindow() 对无窗口进程行为的 XML doc。


🟢 Low(5/5 已修复)

# 文件 问题 修复
L1 DiffPipeline.cs:530-533 CopyUnknownFiles fallback 使用完整绝对路径 ✅ 改为 skip
L2 AbstractStrategy.cs:147 patchRoot 异常时未清理 ✅ 移至 finally
L4 Environments.cs:39 IPC key 无字符校验,可路径遍历 ✅ 白名单校验
L5 IProcessInfoProvider.cs:82-83 冗余 File.Delete ✅ 移除
L7 Bootstrap.cs:580 CallSmallBowlHomeAsync 空名静默 ✅ 记录警告

验证

  • ✅ 三框架编译通过(netstandard2.0 / net8.0 / net10.0),0 错误 0 新警告
  • ✅ 16 文件修改,+207 / −33 行
  • ✅ 所有修复不改变现有公开 API 行为

结论

GeneralUpdate.Core 代码审查中发现的全部安全隐患和质量缺陷(17/17)均已通过 PR #516 修复。可以正常使用。

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions