feat: 添加新插件支持及多项功能改进

- 新增磁盘加密、打印审计和剪贴板管控插件支持
- 优化水印插件显示效果,支持中文及更多Unicode字符
- 改进硬件资产收集逻辑,更准确获取磁盘和显卡信息
- 增强API错误处理,添加详细日志记录
- 完善前端界面,新增插件管理页面
- 修复多个UI问题,优化页面过渡效果
- 添加环境变量覆盖配置功能
- 实现插件状态管理API
- 更新文档和变更日志
- 添加安装程序脚本支持
This commit is contained in:
iven
2026-04-10 22:21:05 +08:00
parent 3d39f0e426
commit b5333d8c93
101 changed files with 4487 additions and 661 deletions

View File

@@ -24,4 +24,9 @@ pub use message::{
SoftwareViolationReport, UsbFileOpEntry,
WatermarkConfigPayload, PluginControlPayload,
UsbPolicyPayload, UsbDeviceRule,
DiskEncryptionStatusPayload, DriveEncryptionInfo,
DiskEncryptionConfigPayload,
PrintEventPayload,
ClipboardRulesPayload, ClipboardRule, ClipboardViolationPayload,
PopupBlockStatsPayload, PopupRuleStat,
};

View File

@@ -46,6 +46,7 @@ pub enum MessageType {
// Plugin: Popup Blocker (弹窗拦截)
PopupRules = 0x50,
PopupBlockStats = 0x51,
// Plugin: USB File Audit (U盘文件操作记录)
UsbFileOp = 0x60,
@@ -59,6 +60,17 @@ pub enum MessageType {
// Plugin control
PluginEnable = 0x80,
PluginDisable = 0x81,
// Plugin: Disk Encryption (磁盘加密检测)
DiskEncryptionStatus = 0x90,
DiskEncryptionConfig = 0x93,
// Plugin: Print Audit (打印审计)
PrintEvent = 0x91,
// Plugin: Clipboard Control (剪贴板管控)
ClipboardRules = 0x94,
ClipboardViolation = 0x95,
}
impl TryFrom<u8> for MessageType {
@@ -85,11 +97,17 @@ impl TryFrom<u8> for MessageType {
0x40 => Ok(Self::SoftwareBlacklist),
0x41 => Ok(Self::SoftwareViolation),
0x50 => Ok(Self::PopupRules),
0x51 => Ok(Self::PopupBlockStats),
0x60 => Ok(Self::UsbFileOp),
0x70 => Ok(Self::WatermarkConfig),
0x71 => Ok(Self::UsbPolicyUpdate),
0x80 => Ok(Self::PluginEnable),
0x81 => Ok(Self::PluginDisable),
0x90 => Ok(Self::DiskEncryptionStatus),
0x93 => Ok(Self::DiskEncryptionConfig),
0x91 => Ok(Self::PrintEvent),
0x94 => Ok(Self::ClipboardRules),
0x95 => Ok(Self::ClipboardViolation),
_ => Err(format!("Unknown message type: 0x{:02X}", value)),
}
}
@@ -337,6 +355,93 @@ pub struct UsbDeviceRule {
pub device_name: Option<String>,
}
/// Plugin: Disk Encryption Status (Client → Server)
#[derive(Debug, Serialize, Deserialize)]
pub struct DiskEncryptionStatusPayload {
pub device_uid: String,
pub drives: Vec<DriveEncryptionInfo>,
}
/// Information about a single drive's encryption status.
/// Field names and types match the migration 012 disk_encryption_status table.
#[derive(Debug, Serialize, Deserialize)]
pub struct DriveEncryptionInfo {
pub drive_letter: String,
pub volume_name: Option<String>,
pub encryption_method: Option<String>,
pub protection_status: String, // "On", "Off", "Unknown"
pub encryption_percentage: f64,
pub lock_status: String, // "Locked", "Unlocked", "Unknown"
}
/// Plugin: Disk Encryption Config (Server → Client)
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct DiskEncryptionConfigPayload {
pub enabled: bool,
pub report_interval_secs: u64,
}
/// Plugin: Print Event (Client → Server)
/// Field names and types match the migration 013 print_events table.
#[derive(Debug, Serialize, Deserialize)]
pub struct PrintEventPayload {
pub device_uid: String,
pub document_name: Option<String>,
pub printer_name: Option<String>,
pub pages: Option<i32>,
pub copies: Option<i32>,
pub user_name: Option<String>,
pub file_size_bytes: Option<i64>,
pub timestamp: String,
}
/// Plugin: Clipboard Rules (Server → Client)
/// Pushed from server to client to define clipboard operation policies.
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct ClipboardRulesPayload {
pub rules: Vec<ClipboardRule>,
}
/// A single clipboard control rule.
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct ClipboardRule {
pub id: i64,
pub rule_type: String, // "block" | "allow"
pub direction: String, // "out" | "in" | "both"
pub source_process: Option<String>,
pub target_process: Option<String>,
pub content_pattern: Option<String>,
}
/// Plugin: Clipboard Violation (Client → Server)
/// Field names and types match the migration 014 clipboard_violations table.
#[derive(Debug, Serialize, Deserialize)]
pub struct ClipboardViolationPayload {
pub device_uid: String,
pub source_process: Option<String>,
pub target_process: Option<String>,
pub content_preview: Option<String>,
pub action_taken: String, // "blocked" | "allowed"
pub timestamp: String,
}
/// Plugin: Popup Block Stats (Client → Server)
/// Periodic statistics from the popup blocker plugin.
#[derive(Debug, Serialize, Deserialize)]
pub struct PopupBlockStatsPayload {
pub device_uid: String,
pub blocked_count: u32,
pub rule_stats: Vec<PopupRuleStat>,
pub period_secs: u64,
}
/// Statistics for a single popup blocker rule.
#[derive(Debug, Serialize, Deserialize)]
pub struct PopupRuleStat {
pub rule_id: i64,
pub hits: u32,
}
#[cfg(test)]
mod tests {
use super::*;