diff --git a/ghost-core/src/live_feeds.rs b/ghost-core/src/live_feeds.rs index 19e60ec..4af4ef6 100644 --- a/ghost-core/src/live_feeds.rs +++ b/ghost-core/src/live_feeds.rs @@ -293,9 +293,7 @@ impl LiveThreatFeeds { indicator.get("type").and_then(|t| t.as_str()), ) { // Map OTX threat level to our scale - let threat_level = indicator - .get("expiration").map(|_| 4) - .unwrap_or(3); + let threat_level = indicator.get("expiration").map(|_| 4).unwrap_or(3); iocs.push(CachedIOC { value: value.to_string(), diff --git a/ghost-core/src/process.rs b/ghost-core/src/process.rs index 2d80c17..3372ed2 100644 --- a/ghost-core/src/process.rs +++ b/ghost-core/src/process.rs @@ -383,11 +383,7 @@ mod platform { fn proc_pidpath(pid: c_int, buffer: *mut c_void, buffersize: u32) -> c_int; } - let ret = proc_pidpath( - pid as c_int, - buffer.as_mut_ptr() as *mut c_void, - size, - ); + let ret = proc_pidpath(pid as c_int, buffer.as_mut_ptr() as *mut c_void, size); if ret > 0 { let path_bytes = &buffer[..ret as usize]; diff --git a/ghost-core/src/yara_engine.rs b/ghost-core/src/yara_engine.rs index 2fd7875..755c9b0 100644 --- a/ghost-core/src/yara_engine.rs +++ b/ghost-core/src/yara_engine.rs @@ -216,7 +216,8 @@ impl DynamicYaraEngine { #[cfg(not(feature = "yara-scanning"))] pub fn compile_rules(&mut self) -> Result { Err(GhostError::Configuration { - message: "YARA scanning is not enabled. Build with --features yara-scanning to enable.".to_string(), + message: "YARA scanning is not enabled. Build with --features yara-scanning to enable." + .to_string(), }) } @@ -330,7 +331,8 @@ impl DynamicYaraEngine { _memory_regions: &[MemoryRegion], ) -> Result { Err(GhostError::Configuration { - message: "YARA scanning is not enabled. Build with --features yara-scanning to enable.".to_string(), + message: "YARA scanning is not enabled. Build with --features yara-scanning to enable." + .to_string(), }) } diff --git a/ghost-core/tests/anomaly_test.rs b/ghost-core/tests/anomaly_test.rs index fc1f2ea..5ee6342 100644 --- a/ghost-core/tests/anomaly_test.rs +++ b/ghost-core/tests/anomaly_test.rs @@ -1,4 +1,4 @@ -use ghost_core::{AnomalyDetector, ProcessInfo, MemoryRegion, MemoryProtection}; +use ghost_core::{AnomalyDetector, MemoryProtection, MemoryRegion, ProcessInfo}; use std::path::PathBuf; #[test] @@ -53,14 +53,12 @@ fn test_anomaly_analysis() { thread_count: 5, }; - let regions = vec![ - MemoryRegion { - base_address: 0x1000, - size: 4096, - protection: MemoryProtection::ReadExecute, - region_type: "IMAGE".to_string(), - }, - ]; + let regions = vec![MemoryRegion { + base_address: 0x1000, + size: 4096, + protection: MemoryProtection::ReadExecute, + region_type: "IMAGE".to_string(), + }]; let features = detector.extract_features(&process, ®ions, None); @@ -84,14 +82,12 @@ fn test_profile_persistence() { thread_count: 5, }; - let regions = vec![ - MemoryRegion { - base_address: 0x1000, - size: 4096, - protection: MemoryProtection::ReadExecute, - region_type: "IMAGE".to_string(), - }, - ]; + let regions = vec![MemoryRegion { + base_address: 0x1000, + size: 4096, + protection: MemoryProtection::ReadExecute, + region_type: "IMAGE".to_string(), + }]; for _ in 0..15 { let features = detector.extract_features(&process, ®ions, None); @@ -101,11 +97,19 @@ fn test_profile_persistence() { let temp_path = PathBuf::from("/tmp/ghost_test_profiles.json"); let save_result = detector.save_profiles(&temp_path); - assert!(save_result.is_ok(), "Failed to save profiles: {:?}", save_result.err()); + assert!( + save_result.is_ok(), + "Failed to save profiles: {:?}", + save_result.err() + ); let mut detector2 = AnomalyDetector::new(); let load_result = detector2.load_profiles(&temp_path); - assert!(load_result.is_ok(), "Failed to load profiles: {:?}", load_result.err()); + assert!( + load_result.is_ok(), + "Failed to load profiles: {:?}", + load_result.err() + ); assert!(!detector2.get_all_profiles().is_empty()); @@ -125,14 +129,12 @@ fn test_global_baseline_computation() { thread_count: 5, }; - let regions = vec![ - MemoryRegion { - base_address: 0x1000, - size: 4096, - protection: MemoryProtection::ReadExecute, - region_type: "IMAGE".to_string(), - }, - ]; + let regions = vec![MemoryRegion { + base_address: 0x1000, + size: 4096, + protection: MemoryProtection::ReadExecute, + region_type: "IMAGE".to_string(), + }]; for _ in 0..15 { let features = detector.extract_features(&process, ®ions, None); @@ -157,14 +159,12 @@ fn test_profile_cleanup() { thread_count: 5, }; - let regions = vec![ - MemoryRegion { - base_address: 0x1000, - size: 4096, - protection: MemoryProtection::ReadExecute, - region_type: "IMAGE".to_string(), - }, - ]; + let regions = vec![MemoryRegion { + base_address: 0x1000, + size: 4096, + protection: MemoryProtection::ReadExecute, + region_type: "IMAGE".to_string(), + }]; for _ in 0..15 { let features = detector.extract_features(&process, ®ions, None); diff --git a/ghost-core/tests/macos_process_test.rs b/ghost-core/tests/macos_process_test.rs index f43a66a..088abba 100644 --- a/ghost-core/tests/macos_process_test.rs +++ b/ghost-core/tests/macos_process_test.rs @@ -10,7 +10,10 @@ fn test_macos_process_enumeration() { println!("Found {} processes", processes.len()); for proc in processes.iter().filter(|p| p.pid > 0).take(5) { - println!("PID: {}, Name: {}, Path: {:?}", proc.pid, proc.name, proc.path); + println!( + "PID: {}, Name: {}, Path: {:?}", + proc.pid, proc.name, proc.path + ); assert!(proc.pid > 0, "PID should be positive"); assert!(!proc.name.is_empty(), "Process name should not be empty"); } @@ -19,12 +22,21 @@ fn test_macos_process_enumeration() { let current_process = processes.iter().find(|p| p.pid == current_pid); if let Some(proc) = current_process { - println!("Current process found: PID={}, Name={}", proc.pid, proc.name); + println!( + "Current process found: PID={}, Name={}", + proc.pid, proc.name + ); } else { - println!("Current process (PID={}) not in list - this is OK for test processes", current_pid); + println!( + "Current process (PID={}) not in list - this is OK for test processes", + current_pid + ); } - assert!(processes.iter().any(|p| p.pid == 1), "Should at least find launchd (PID 1)"); + assert!( + processes.iter().any(|p| p.pid == 1), + "Should at least find launchd (PID 1)" + ); } #[cfg(target_os = "macos")]