From 868137e2a4501becd1c2692301e9b06289958fb3 Mon Sep 17 00:00:00 2001 From: NK Date: Tue, 10 Feb 2026 15:35:47 +0100 Subject: [PATCH] Fix clippy warnings: use contains(), fix late initialization --- src/lsass/dpapi.rs | 2 +- src/lsass/finder.rs | 7 +------ src/lsass/msv.rs | 2 +- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/lsass/dpapi.rs b/src/lsass/dpapi.rs index 85a8fe2..6318f5b 100644 --- a/src/lsass/dpapi.rs +++ b/src/lsass/dpapi.rs @@ -426,7 +426,7 @@ fn try_dpapi_entry_match(page: &[u8], off: usize) -> bool { // insertTime at +0x28: FILETIME should be a reasonable date (2000-2040) // High DWORD of FILETIME for year 2000 ≈ 0x01BF..., year 2040 ≈ 0x01E0... let ft_high = u32::from_le_bytes(page[off + 0x2C..off + 0x30].try_into().unwrap()); - if ft_high < 0x01BF_0000 || ft_high > 0x01E0_0000 { + if !(0x01BF_0000..=0x01E0_0000).contains(&ft_high) { return false; } // key_size at +0x30: must be 32, 48, or 64 diff --git a/src/lsass/finder.rs b/src/lsass/finder.rs index 9e5f945..76e87f1 100644 --- a/src/lsass/finder.rs +++ b/src/lsass/finder.rs @@ -164,7 +164,6 @@ pub fn extract_all_credentials( let mut wdigest_status = "paged"; let mut kerberos_status = "paged"; let mut tspkg_status = "paged"; - let dpapi_status; let mut ssp_status = "empty"; let mut livessp_status = if dlls.livessp.is_some() { "paged" } else { "n/a" }; let mut credman_status = "paged"; @@ -267,11 +266,7 @@ pub fn extract_all_credentials( crate::lsass::dpapi::extract_dpapi_physical_scan(phys, lsass.dtb, &lsass_vmem, &keys) } }; - if dpapi_creds.is_empty() { - dpapi_status = "empty"; - } else { - dpapi_status = "ok"; - } + let dpapi_status = if dpapi_creds.is_empty() { "empty" } else { "ok" }; for (luid, dpapi_cred) in dpapi_creds { let entry = all_creds.entry(luid).or_insert_with(|| { Credential::new_empty(luid, String::new(), String::new()) diff --git a/src/lsass/msv.rs b/src/lsass/msv.rs index 03861d3..4a58a5b 100644 --- a/src/lsass/msv.rs +++ b/src/lsass/msv.rs @@ -1016,7 +1016,7 @@ fn find_list_addr_and_count(vmem: &impl VirtualMemory, pattern_addr: u64) -> Res for &addr in &lea_addrs { let val = vmem.read_virt_u32(addr).unwrap_or(0); // LogonSessionListCount is typically 64 or another small power-of-2 - if val >= 4 && val <= 256 { + if (4..=256).contains(&val) { count = val as usize; log::info!("LogonSessionListCount at 0x{:x} = {}", addr, val); } else {