mirror of
https://github.com/wwiinnddyy/LanMountainDesktop.git
synced 2026-06-20 23:54:26 +08:00
合并对设置系统的更新 (#11)
* Add Windows system chrome patchers (Harmony) Introduce support for toggling the system chrome on Windows using Harmony patchers. Adds Lib.Harmony.Thin to package props and project, new patcher infrastructure (ChromePatchState, PatcherEntrance) and two Harmony patches that disable FluentAvalonia's Windows chrome when configured. Program.cs now loads the chrome setting and installs patchers conditionally on Windows/x86-x64. Settings viewmodel and view updated: expose IsWindowsOs, require restart on appearance changes, migrate SettingsWindow to FAAppWindow and adapt titlebar/layout (include Windows caption placeholder and footer menu items). Also add a .gitkeep and a build log file. * Refactor settings window UI and theming Improve theming and layout for the Settings window and related services. - MaterialSurfaceService: add special material parameters for SettingsWindowBackground (lower alpha, no blur) and avoid hot-switching real backdrops for non-settings windows. - GlassEffectService: add AdaptiveSettingsWindowTintBrush + ResolveSettingsWindowTintAlpha to provide optional content tinting tied to system material mode. - SettingsWindowService: refactor theme application into ApplyThemeVariantAndResources, ensure settings window material is applied at show/activate times, and tidy theme/resource application flow. - SettingsWindow.axaml / .axaml.cs: restructure title bar (separate Grid.Row=0 border) and FANavigationView host, add pane-footer toggle button for :minimal layout, use dynamic corner radius resource, and update toggle/visibility/icon logic and responsive layout code. - SettingsPages: remove some IconText usages and adjust margins; use DesignCornerRadiusLg for update card corner radius. - Add NuGet.Config to set local globalPackagesFolder and ignore .nuget/packages in .gitignore. These changes aim to improve visuals, avoid backdrop overdraw, and make the settings window behavior consistent across themes and layouts. * Add localization and localize settings pages Add many new localization keys (en-US and zh-CN) for notifications, developer tools, about page, status bar, and video wallpaper. Update Notification, Dev, About and StatusBar view models to use LocalizationService, expose localized ObservableProperties, and refresh localized text at construction. Localize selection options and test notification texts, and fix notification severity handling. Wire up XAML to the new localized properties (About/Dev/StatusBar pages) and update the settings page title for notifications. Also adjust copyright line generation and replace hardcoded placeholders with bound Watermark properties. * Redesign settings window with fluent shell & search Rebuild the settings window as a Fluent shell: adds a custom 48-DIP titlebar with Back, pane toggle, icon/title, search box, restart/more menu, and caption-button spacer; moves compact pane toggle into the titlebar and preserves FANavigationView as the primary navigation surface. Introduces a SettingsSearchService (with UI AutoComplete integration, search indexing, navigation-by-result, and search result highlighting) plus focused tests for search filtering and theme material normalization. Adds navigation history/back stack, updates SettingsViewModels for new bindings and localization keys, and updates General/Apearance pages to expose new strings and options. Implements an "auto" system material mode: default in AppSettingsSnapshot, new MaterialAuto constants and normalization/resolution logic in ThemeAppearanceValues, WindowMaterialService and MaterialSurfaceService adjustments to prefer Mica on Win11 and Acrylic on Win10 using TransparencyLevelHint. GlassEffectService and AppearanceThemeService updated to use effective material mode and to track live theme state changes. Adds localization entries (en-US, zh-CN), spec/tasks docs, and other UI/style tweaks to support the redesign. * fix.修折叠与展开按钮 * Add OOBE startup presentation and settings merge Introduce a new OOBE step for "Startup & Presentation" that exposes startup and UI preferences in OobeWindow (toggles for taskbar, slide/fade transitions, fused popup, and autostart). Add HostAppSettingsOobeMerger to read/write Host settings.json (PascalCase fields) and MergeStartupPresentation behavior, plus LauncherWindowsStartupService to sync the current Launcher into the Windows Run key on Windows. Wire UI handlers, persist choices on Next, and load defaults when entering the step. Include unit tests for the merger, adjust SettingsWindow navigation pane/toggle handling, and update docs/LAUNCHER.md to describe the new OOBE step and implementation files. * Move whiteboard persistence to file storage Switch whiteboard note storage from legacy DB rows to per-note JSON files and add migration support. Update WhiteboardNoteSnapshot schema (version bump, viewport, canvas, expires, PathSvgData) and change IWhiteboardNotePersistenceService.SaveNote to return bool to surface write failures (e.g. read-only files). Implement file-based WhiteboardNotePersistenceService with legacy DB migration/cleanup, retention handling, and logging. Add comprehensive unit tests for persistence, stroke path builder, SVG import and viewport helper. Also add ThirdParty/DotNetCampus.InkCanvas project and reference it in the main csproj, and bump PostHog package to 2.6.0. * Introduce render gate and chart caching Replace UI DispatcherTimer polling with a StudySnapshotRenderGate across multiple widgets to queue and apply only the latest analytics snapshot; components updated include StudyDeductionReasonsWidget, StudyEnvironmentWidget, StudyInterruptDensityWidget, StudyNoiseCurveWidget. Add StudySnapshotRenderGate implementation to coordinate rendering and monitoring leases and update subscription/lease lifecycle handling (subscribe/unsubscribe, Acquire/Dispose leases, Clear/Dispose gate). Rewrite chart controls (StudyNoiseCurveChartControl and StudyNoiseDistributionScatterChartControl) to use stable logical-time origins, split series into static vs dynamic tails, add geometry/sample caching, stable jitter/coordinate mapping helpers, and expose internal helpers & counts for testing. Add unit tests (StudyComponentRenderingTests) covering the render gate and chart behaviors (layer counts, logical X mapping, stable jitter, cache rebuild). These changes improve rendering correctness and performance by avoiding redundant renders and enabling deterministic chart layout. * Use MaterialColorSnapshot in appearance flow Introduce unified material/color spec and tests, and refactor appearance plumbing to use MaterialColorSnapshot as the single source of truth. Add .trae material-color-service spec/checklist/tasks and integration/unit tests for plugin mapping and appearance VM behavior. AppearanceChangedEvent extended with new appearance change flags and HasChanged logic. ComponentEditorMaterialThemeAdapter rewritten to accept MaterialColorSnapshot and derive palette from snapshot data. Simplify AppearanceSettingsPageViewModel and related view code: remove legacy preview/custom-seed UI logic, preserve material/color fields when updating theme or corner radius, and update save calls to use with-expressions. Update ComponentEditorWindow to use adapter-provided OnPrimary brush and minor docs updates. * Add material color services, plugin DTOs, and tests Introduce IPC wire-format appearance DTOs (PluginIsolation.Contracts) and clarify they are distinct from the runtime PluginSdk snapshot. Update PluginSdk comments to document the runtime-facing snapshot shape. Change ComponentColorSchemeHelper to use the HostMaterialColorProvider and add an overload that accepts a MaterialColorSnapshot. Add new services and pipelines (MaterialColorService, MaterialSurfaceService, WindowMaterialService, WallpaperColorPipeline) and refactor AppearanceThemeService to depend on MaterialColorService while removing legacy internal implementations. Add multiple unit tests (ComponentColorSchemeHelper, PluginAppearanceBoundary, SettingsCatalogService, WallpaperSettingsPageViewModel) and update localization resources with new material_color and wallpaper keys. * Add CODE_WIKI and update localization Add a comprehensive CODE_WIKI.md documenting project architecture, modules, startup flow, plugin system, testing and developer workflows. Update localization resources (en-US.json, zh-CN.json) with new/translated keys for wallpaper controls (custom color UI), material & color settings (semantic roles, surfaces, refresh/polling state), appearance (corner radius), status bar font size options, privacy policy text, component library labels, clock settings, and new language entry (Korean). Also modify settings-related ViewModels and Settings page views to surface these new features and texts (MaterialColorSettingsPageViewModel.cs, SettingsViewModels.cs, WallpaperSettingsPageViewModel.cs, MainWindow.SettingsHardCut.Stubs.cs, ComponentsSettingsPage.axaml, WallpaperSettingsPage.axaml). * Add Data settings page and storage scanner Introduce a new "Data" settings page to visualize and manage local app storage. Adds DataStorageService (scanning, disk info, clean operations), DataSettingsPageViewModel, XAML view and code-behind, and HexToColor/HexToBrush converters; registers converters in App.axaml. Also update localization strings for the new page and add icon mapping so the settings entry uses the Database icon. Enables per-category and global cleaning workflows and formatted size display. * Add IPC backoff/retries and safer disposal Introduce exponential backoff, jitter and retry logic across IPC components to improve robustness and avoid tight retry loops; make disposal idempotent and add connection guards. Key changes: - LauncherCoordinatorIpcServer / LauncherIpcServer: add backoff constants, ComputeBackoff(), consecutive error tracking and delayed retries with jitter. - LanMountainDesktopIpcClient / LauncherIpcClient: add connect retry loops, timeouts, delayed retries, improved error logging, and use ArrayPool for buffered async writes; ensure proper cleanup on failures. - PublicIpcHostService: add disposed flag, guard OnPeerConnected and Dispose, and clear connected peers on dispose. - Add many auto-generated commit analysis docs under docs/auto_commit_md and new scripts for analyzing/generating commit docs. These changes aim to make IPC connection handling more resilient and resource-safe. * Add preview controls and settings UI tweaks Introduce GridPreviewControl and CornerRadiusPreviewControl for visual previews and wire them into the Components settings (add ScreenAspectRatio, CornerRadiusPreviewValue, and screen aspect init). Refactor ComponentsSettingsPage UI to show live previews. Improve DataSettingsPage layout and storage bar logic (use item percentages directly, include remaining segment, adjust visuals and visibility triggers). Simplify LauncherSettingsPage header/appearance layout. Add SECURITY_AUDIT_REPORT.md, analysis summary, mockup HTML, and a local .claude settings file. * Add install checkpoint/resume and DDSS workflows Introduce install checkpoint support and resume logic for updates, plus related locking and validation. Adds InstallCheckpoint model, AppJsonContext serialization, and UpdatePaths helpers for deployment lock, apply-in-progress lock and install-checkpoint path. UpdateEngineService gains checkpoint load/save/delete, incoming-state validation, resume logic for PLONDS and legacy updates, apply lock handling, and safer cleanup; ApplyPendingPlondsUpdateAsync and ApplyPendingUpdate flow updated accordingly. Add DeploymentLock contract and extend UpdateState with pause/resume/cancel helpers. Tests updated to cover stale/valid checkpoint resume and legacy/PLONDS flows. CI: enhance ddss-publish to detect release channel, validate S3 assets, prepare and atomically publish channel pointer; add ddss-rollback workflow to publish rollbacks; adjust plonds-build concurrency and release events. * changed.更了好多 * fix.消息盒子媒体播放器组件服务修复 * change.重做天气,为回到系统提供自定义功能。 * feat.airapp与融合桌面 * feat.动画优化与更新界面 * feat.数字时钟,白板功能修复 * feat.完善了时钟轻应用,为启动器提供了多语言支持 * feat.发布与打包优化 * changed.天气选项卡更新
This commit is contained in:
196
SECURITY_AUDIT_REPORT.md
Normal file
196
SECURITY_AUDIT_REPORT.md
Normal file
@@ -0,0 +1,196 @@
|
||||
# 安全审计报告
|
||||
|
||||
**项目**: LanMountainDesktop
|
||||
**审计日期**: 2026-05-11
|
||||
**审计范围**: 整体代码库安全性评估
|
||||
**审计方法**: 自动化静态代码分析 + 架构审查
|
||||
|
||||
---
|
||||
|
||||
## 执行摘要
|
||||
|
||||
本次审计对 LanMountainDesktop 代码库进行了系统性安全评估,重点关注认证与访问控制、注入向量、外部交互以及敏感数据处理等高风险攻击面。
|
||||
|
||||
**审计结论**: 发现 **4 个已确认的中等及以上严重度漏洞**,建议立即修复。
|
||||
|
||||
---
|
||||
|
||||
## 已确认漏洞
|
||||
|
||||
### 漏洞 #1 - PostHog API Key 硬编码(高严重度)
|
||||
|
||||
| 属性 | 详情 |
|
||||
|------|------|
|
||||
| **严重度** | 高 |
|
||||
| **CWE** | CWE-798 - 使用硬编码凭证 |
|
||||
| **位置** | `LanMountainDesktop/Services/PostHogUsageTelemetryService.cs:14` |
|
||||
| **攻击者画像** | 源代码仓库的任何访问者(包括外部攻击者通过代码泄露或供应链攻击) |
|
||||
| **可控输入** | 无(静态硬编码密钥) |
|
||||
|
||||
**代码路径**:
|
||||
```csharp
|
||||
// PostHogUsageTelemetryService.cs:14
|
||||
private const string PostHogApiKey = "phc_bhQZvKDDfsEdLT6kkRFvrWMT8Pc5aCGGsnxoc5ijSf9";
|
||||
```
|
||||
|
||||
**影响**:
|
||||
- 攻击者可能滥用此 API Key 向 PostHog 项目发送伪造遥测数据
|
||||
- 可能导致遥测数据污染或服务滥用
|
||||
- API Key 暴露在公开仓库中,任何人都能获取
|
||||
|
||||
**修复建议**:
|
||||
```csharp
|
||||
private const string PostHogApiKey = Environment.GetEnvironmentVariable("POSTHOG_API_KEY")
|
||||
?? throw new InvalidOperationException("PostHog API key not configured.");
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 漏洞 #2 - Sentry DSN 硬编码(高严重度)
|
||||
|
||||
| 属性 | 详情 |
|
||||
|------|------|
|
||||
| **严重度** | 高 |
|
||||
| **CWE** | CWE-798 - 使用硬编码凭证 |
|
||||
| **位置** | `LanMountainDesktop/Services/SentryCrashTelemetryService.cs:15` |
|
||||
| **攻击者画像** | 源代码仓库的任何访问者 |
|
||||
| **可控输入** | 无(静态硬编码密钥) |
|
||||
|
||||
**代码路径**:
|
||||
```csharp
|
||||
// SentryCrashTelemetryService.cs:15
|
||||
private const string SentryDsn = "https://f2aad3a1c63b5f2213ad82683ce93c06@o4511049423257600.ingest.us.sentry.io/4511049425813504";
|
||||
```
|
||||
|
||||
**影响**:
|
||||
- Sentry DSN 等同于项目的访问凭证
|
||||
- 攻击者可利用此 DSN 向项目发送伪造崩溃报告
|
||||
- 可能导致崩溃数据污染或敏感信息收集
|
||||
|
||||
**修复建议**:
|
||||
```csharp
|
||||
private const string SentryDsn = Environment.GetEnvironmentVariable("SENTRY_DSN")
|
||||
?? throw new InvalidOperationException("Sentry DSN not configured.");
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 漏洞 #3 - 小米天气 API 签名密钥硬编码(高严重度)
|
||||
|
||||
| 属性 | 详情 |
|
||||
|------|------|
|
||||
| **严重度** | 高 |
|
||||
| **CWE** | CWE-798 - 使用硬编码凭证 |
|
||||
| **位置** | `LanMountainDesktop/Services/XiaomiWeatherService.cs:25` |
|
||||
| **攻击者画像** | 源代码仓库的任何访问者 |
|
||||
| **可控输入** | 无(静态硬编码密钥) |
|
||||
|
||||
**代码路径**:
|
||||
```csharp
|
||||
// XiaomiWeatherService.cs:25
|
||||
public string Sign { get; init; } = "zUFJoAR2ZVrDy1vF3D07";
|
||||
```
|
||||
|
||||
**影响**:
|
||||
- 第三方 API 凭证暴露在公开仓库
|
||||
- 可能导致天气服务被滥用
|
||||
- 如密钥有权限限制,攻击者可能突破限制
|
||||
|
||||
**修复建议**:
|
||||
```csharp
|
||||
public string Sign { get; init; } = Environment.GetEnvironmentVariable("XIAOMI_WEATHER_SIGN") ?? "";
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 漏洞 #4 - Sentry PII 收集配置(中等严重度)
|
||||
|
||||
| 属性 | 详情 |
|
||||
|------|------|
|
||||
| **严重度** | 中等 |
|
||||
| **CWE** | CWE-359 - 个人身份信息(PII)意外暴露 |
|
||||
| **位置** | `LanMountainDesktop/Services/SentryCrashTelemetryService.cs:212` |
|
||||
| **攻击者画像** | Sentry 后端管理员、内部威胁或数据泄露事件 |
|
||||
| **可控输入** | 用户环境的机器名、用户名等系统信息 |
|
||||
| **利用路径** | `程序启动 → TelemetryIdentityService.Initialize()` → 遥测数据上报 |
|
||||
|
||||
**代码路径**:
|
||||
```csharp
|
||||
// SentryCrashTelemetryService.cs:212
|
||||
options.SendDefaultPii = true;
|
||||
```
|
||||
|
||||
**影响**:
|
||||
- `SendDefaultPii = true` 配置会收集和上报用户 IP 地址
|
||||
- 可能违反隐私法规(如 GDPR)要求
|
||||
- 在崩溃报告中可能暴露用户敏感信息
|
||||
|
||||
**修复建议**:
|
||||
```csharp
|
||||
options.SendDefaultPii = false; // 默认收集 PII
|
||||
options.SendDefaultPii = TelemetryEnvironmentInfo.IsTelemetryPiiAllowed(); // 或根据用户同意状态动态设置
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 未发现漏洞的区域
|
||||
|
||||
经过系统性审计,以下区域未发现中等及以上严重度的已确认漏洞:
|
||||
|
||||
### 认证与访问控制
|
||||
- 单实例服务实现正确(使用互斥体)
|
||||
- IPC 通信使用命名管道,无明显认证绕过风险
|
||||
- 插件隔离使用独立进程边界
|
||||
|
||||
### 注入向量
|
||||
- SQLite 使用参数化查询,无 SQL 注入风险
|
||||
- JSON 反序列化使用强类型上下文,无反序列化漏洞
|
||||
- 文件路径操作使用 `Path.Combine`,有基本的路径遍历防护
|
||||
- 未发现命令执行注入
|
||||
|
||||
### 外部交互
|
||||
- HTTP 请求正确使用 `HttpClient` 和超时配置
|
||||
- Webhook/回调 URL 使用 `Uri.EscapeDataString` 编码
|
||||
- 下载服务验证目标路径,无路径遍历风险
|
||||
|
||||
### 敏感数据处理
|
||||
- 数据库本地存储,使用 WAL 模式
|
||||
- 设置数据通过 JSON 序列化存储在用户目录
|
||||
- 日志文件路径正确隔离在应用数据目录
|
||||
|
||||
---
|
||||
|
||||
## 架构安全评估
|
||||
|
||||
| 组件 | 安全评级 | 说明 |
|
||||
|------|----------|------|
|
||||
| 插件系统 | 良好 | 使用独立进程隔离 |
|
||||
| IPC 通信 | 良好 | 命名管道通信,进程边界隔离 |
|
||||
| 更新系统 | 良好 | 支持签名验证 |
|
||||
| 遥测系统 | **需改进** | 存在硬编码凭证和 PII 配置问题 |
|
||||
| 数据存储 | 良好 | 使用标准加密实践 |
|
||||
|
||||
---
|
||||
|
||||
## 修复优先级
|
||||
|
||||
| 优先级 | 漏洞 | 预计工作量 |
|
||||
|--------|------|------------|
|
||||
| P0 - 紧急 | #1 PostHog API Key | 低 |
|
||||
| P0 - 紧急 | #2 Sentry DSN | 低 |
|
||||
| P0 - 紧急 | #3 Xiaomi Weather Sign | 低 |
|
||||
| P1 - 高 | #4 SendDefaultPii | 低 |
|
||||
|
||||
---
|
||||
|
||||
## 建议的安全改进
|
||||
|
||||
1. **实施密钥管理**: 使用环境变量或密钥管理服务(如 Azure Key Vault、AWS Secrets Manager)存储所有 API 凭证
|
||||
2. **添加密钥扫描**: 在 CI/CD 流程中集成 secrets scanning(如 GitGuardian、trufflehog)
|
||||
3. **隐私合规审查**: 确认遥测数据收集符合当地隐私法规要求
|
||||
4. **代码审计**: 建议进行定期安全审计
|
||||
|
||||
---
|
||||
|
||||
*报告生成工具: 自动安全审计系统*
|
||||
*审计方法: 静态代码分析 + 架构审查*
|
||||
Reference in New Issue
Block a user