128 lines
5.4 KiB
Markdown
128 lines
5.4 KiB
Markdown
# 日志映射分析最终报告
|
||
|
||
## 执行摘要
|
||
|
||
本次分析对 MiDM 系统的日志记录机制进行了全面调查,通过分析 javap 反编译文件,查找用户操作到日志条目的映射关系。
|
||
|
||
### 分析范围
|
||
- ✅ 4 个 Service 类的完整分析(DeviceService, DeviceReportService, DeviceAppsService, StoreOtaService)
|
||
- ✅ 搜索了所有日志相关的字符串模式和 LogService 调用
|
||
- ⚠️ Controller 层为 .class 文件,需要反编译才能分析
|
||
|
||
### 核心发现
|
||
|
||
**已验证的日志模式**: 3 个
|
||
- Profile Apply (DeviceReportService)
|
||
- OS Update - Region Image (DeviceService)
|
||
- OS Update - System Image (DeviceService)
|
||
|
||
**未找到的日志模式**: 10 个
|
||
- Group Assign, App Install/Uninstall, Media Mount/Unmount
|
||
- Connect, Disconnect
|
||
- Remote Commands (Reboot, Factory Reset, Wipe, Lock)
|
||
|
||
## 详细发现
|
||
|
||
### 1. 已验证的日志记录
|
||
|
||
#### Profile Apply
|
||
- **位置**: `DeviceReportService.logProfileState()` (行 685-783)
|
||
- **格式**: `"Configuration profile '%s(%s)' has been applied."`
|
||
- **Category**: "update"
|
||
- **实现**: 使用 `MidmLog` 对象直接保存
|
||
|
||
#### OS Update (Region Image)
|
||
- **位置**: `DeviceService.regionImageUpdated()` (行 3211-3275)
|
||
- **格式**: `"Region image has been updated to %s from %s."`
|
||
- **Category**: "activity"
|
||
- **实现**: 使用 `logService.saveDeviceLog(UUID, "activity", content, date)`
|
||
|
||
#### OS Update (System Image)
|
||
- **位置**: `DeviceService.systemImageUpdated()` (行 3156-3209)
|
||
- **格式**: `"System image has been %s to %s from %s."`
|
||
- **Category**: "activity"
|
||
- **实现**: 使用 `logService.saveDeviceLog(UUID, "activity", content, date)`
|
||
|
||
### 2. 连接/断开连接状态管理
|
||
|
||
在 `DeviceService.updateOnlineState()` (行 2752-2795) 中发现:
|
||
- ✅ 更新 `states.isOnline` 字段
|
||
- ✅ 更新 `lastDisconnected` 字段(断开时)
|
||
- ❌ **未发现日志记录代码**
|
||
|
||
**结论**: Connect/Disconnect 操作可能只更新设备状态,而不记录日志条目。
|
||
|
||
### 3. LogService 使用模式
|
||
|
||
在 DeviceService 中发现以下 LogService 方法调用:
|
||
1. `logService.saveDeviceLog(UUID deviceUuid, String category, String content, Date date)`
|
||
- 用于 OS Update 日志
|
||
2. `logService.save(MidmLog log)`
|
||
- 用于保存 MidmLog 对象
|
||
3. `logService.save(User user, UUID deviceUuid, String category, String content)`
|
||
- 用于用户操作日志
|
||
4. `logService.clearAllLogsFor(UUID deviceUuid)`
|
||
- 用于清除设备所有日志
|
||
|
||
### 4. 未找到的日志模式分析
|
||
|
||
#### App Install/Uninstall
|
||
- `DeviceAppsService.removeDeviceApp()` 方法存在,但仅执行数据库更新
|
||
- 未找到 "App(%s) has been added." 或 "App(%s) has been removed." 的日志记录代码
|
||
- **推测**: 可能由设备端记录并通过 DeviceReport 上报
|
||
|
||
#### Media Mount/Unmount
|
||
- 在 DeviceReportService 中未找到相关日志记录代码
|
||
- **推测**: 可能由设备端记录并通过 DeviceReport 上报
|
||
|
||
#### Connect/Disconnect
|
||
- 找到 `updateOnlineState()` 方法更新状态字段
|
||
- 未找到 "Connected-%s" 或 "Disconnected(%s)" 的日志记录代码
|
||
- **推测**: 可能只更新状态,不记录日志;或日志在 WebSocketSessionManager 中记录
|
||
|
||
#### Remote Commands
|
||
- 搜索 "reboot", "factory reset", "wipe", "lock", "remote command" 未找到相关代码
|
||
- **推测**: 日志可能在 Controller 层(DeviceController 或 WebSocket Handler)中记录
|
||
|
||
#### Group Assign
|
||
- 搜索 "Device group assigned" 未找到
|
||
- **推测**: 日志可能在设备组分配的其他服务类中记录
|
||
|
||
## 技术限制
|
||
|
||
1. **.class 文件限制**: Controller 层和服务类为编译后的字节码,需要反编译才能分析
|
||
2. **代码覆盖**: 仅分析了部分 Service 类,可能还有其他服务类包含日志记录代码
|
||
3. **运行时行为**: 静态分析无法捕获运行时动态生成的日志内容
|
||
4. **客户端代码**: 无法分析设备端代码,可能包含部分日志记录逻辑
|
||
|
||
## 建议的下一步行动
|
||
|
||
### 优先级 1: 反编译关键类
|
||
1. **LogService.class** - 了解完整的日志记录机制和所有日志格式
|
||
2. **DeviceController.class** - 查看 REST API 中的日志记录
|
||
3. **WebSocketSessionManager.class** - 查看 WebSocket 连接/断开时的日志记录
|
||
4. **MidmWebSocketSession.class** - 查看 WebSocket 会话处理中的日志记录
|
||
|
||
### 优先级 2: 检查数据模型
|
||
1. **DeviceReport 模型** - 检查是否包含日志相关字段或通过 DeviceReport 上报日志
|
||
2. **MidmLog 模型** - 了解日志数据结构和所有可能的日志类型
|
||
|
||
### 优先级 3: 实际数据验证
|
||
1. 查看实际日志数据库中的记录
|
||
2. 验证日志格式和内容
|
||
3. 确认未找到的日志模式是否真的不存在,或使用不同的格式
|
||
|
||
### 优先级 4: 客户端代码分析
|
||
1. 如果可能,分析设备端代码,查看 App/Media 相关日志的记录方式
|
||
2. 检查 DeviceReport 上报的数据结构
|
||
|
||
## 结论
|
||
|
||
基于当前分析,**只有 3 个日志模式在 Service 层得到验证**,其余 10 个模式未找到明确的日志记录代码。这强烈表明:
|
||
|
||
1. **大部分日志可能在其他层记录**: Controller 层、WebSocket 层或客户端
|
||
2. **使用不同的日志记录机制**: 可能通过 DeviceReport 上报,或使用不同的日志格式
|
||
3. **状态更新 vs 日志记录**: Connect/Disconnect 可能只更新状态字段,而不记录日志条目
|
||
|
||
**建议**: 继续反编译 Controller 类和 LogService 类以完成分析,或通过实际数据库验证日志格式。
|