ruvector_memopt/security/
integrity.rs1use std::path::Path;
4use std::collections::HashMap;
5
6pub struct IntegrityChecker {
8 expected_hashes: HashMap<String, String>,
9}
10
11impl IntegrityChecker {
12 pub fn new() -> Self {
13 Self {
14 expected_hashes: HashMap::new(),
15 }
16 }
17
18 pub fn verify_file(&self, path: &Path) -> Result<bool, String> {
20 if !path.exists() {
21 return Err(format!("File not found: {:?}", path));
22 }
23
24 Ok(true)
26 }
27
28 pub fn verify_installation(&self, install_dir: &Path) -> VerificationResult {
30 let mut result = VerificationResult::default();
31
32 let exe_path = install_dir.join("ruvector-memopt.exe");
34 if exe_path.exists() {
35 result.files_checked += 1;
36 result.files_valid += 1;
37 } else {
38 result.errors.push("Main executable not found".into());
39 }
40
41 let data_dir = install_dir.join("data");
43 if !data_dir.exists() {
44 result.warnings.push("Data directory missing - will be created".into());
45 }
46
47 result.is_valid = result.errors.is_empty();
48 result
49 }
50}
51
52#[derive(Debug, Default)]
53pub struct VerificationResult {
54 pub is_valid: bool,
55 pub files_checked: usize,
56 pub files_valid: usize,
57 pub errors: Vec<String>,
58 pub warnings: Vec<String>,
59}
60
61impl VerificationResult {
62 pub fn print_report(&self) {
63 println!("Installation Verification Report");
64 println!("================================");
65 println!("Status: {}", if self.is_valid { "VALID" } else { "INVALID" });
66 println!("Files checked: {}", self.files_checked);
67 println!("Files valid: {}", self.files_valid);
68
69 if !self.errors.is_empty() {
70 println!("\nErrors:");
71 for e in &self.errors {
72 println!(" - {}", e);
73 }
74 }
75
76 if !self.warnings.is_empty() {
77 println!("\nWarnings:");
78 for w in &self.warnings {
79 println!(" - {}", w);
80 }
81 }
82 }
83}
84
85impl Default for IntegrityChecker {
86 fn default() -> Self { Self::new() }
87}