From 9a52c3936779589dc6206439fc6cf814ce523d6b Mon Sep 17 00:00:00 2001 From: Brad Swain Date: Thu, 19 Feb 2026 12:27:54 -0600 Subject: [PATCH 1/3] update sysinfo to 0.38.2 --- checksec.rs/Cargo.toml | 2 +- checksec.rs/src/main.rs | 49 +++++++++++++++++++++++++++-------------- 2 files changed, 33 insertions(+), 18 deletions(-) diff --git a/checksec.rs/Cargo.toml b/checksec.rs/Cargo.toml index 2ef6716..17fb731 100644 --- a/checksec.rs/Cargo.toml +++ b/checksec.rs/Cargo.toml @@ -35,7 +35,7 @@ scroll = "0.13.0" serde = { version = "1.0.145", features = ["derive"] } serde_derive = "1.0.145" serde_json = "1.0.86" -sysinfo = "0.28.2" +sysinfo = "0.38.2" flate2 = "1.1.2" base64 = "0.22.1" bincode = { version = "2.0.1", features = ["serde"] } diff --git a/checksec.rs/src/main.rs b/checksec.rs/src/main.rs index 504db20..bab8f9c 100644 --- a/checksec.rs/src/main.rs +++ b/checksec.rs/src/main.rs @@ -6,7 +6,6 @@ extern crate core; extern crate goblin; extern crate ignore; extern crate serde_json; -extern crate sysinfo; use clap::{ crate_authors, crate_description, crate_version, Arg, ArgAction, ArgGroup, @@ -25,9 +24,7 @@ use memmap2::Mmap; use rayon::iter::ParallelBridge; use rayon::prelude::*; use serde_json::{json, to_string_pretty}; -use sysinfo::{ - PidExt, ProcessExt, ProcessRefreshKind, RefreshKind, System, SystemExt, -}; +use sysinfo::{ProcessRefreshKind, RefreshKind, System, UpdateKind}; use std::collections::HashMap; #[cfg(all(target_os = "linux", feature = "elf"))] @@ -643,7 +640,9 @@ fn parse_process_libraries( .into_iter() .filter(|m| m.flags.x) .filter_map(|m| m.pathname) - .filter(|p| p.is_absolute() && p != process.exe()) + .filter(|p| { + p.is_absolute() && process.exe().is_none_or(|exe| p != exe) + }) .map(|p| match p.file_name() { Some(file_name) => match file_name.to_str() { Some(file_name) => { @@ -708,7 +707,11 @@ where processes .par_bridge() .filter_map(|process| { - match parse(process.exe(), &mut Some(Arc::clone(&cache))) { + let exe = match process.exe() { + Some(exe) => exe, + None => return None, + }; + match parse(exe, &mut Some(Arc::clone(&cache))) { Err(err) => { if let ParseError::IO(ref e) = err { if e.kind() == ErrorKind::NotFound @@ -720,7 +723,7 @@ where eprintln!( "Can not parse process {} with ID {}: {}", - process.name(), + process.name().to_string_lossy(), process.pid(), err ); @@ -876,8 +879,11 @@ fn main() { if procall { let system = System::new_with_specifics( - RefreshKind::new() - .with_processes(ProcessRefreshKind::new().with_cpu()), + RefreshKind::nothing().with_processes( + ProcessRefreshKind::nothing() + .with_cpu() + .with_exe(UpdateKind::OnlyIfNotSet), + ), ); let procs = parse_processes(system.processes().values(), libraries); @@ -895,8 +901,11 @@ fn main() { }) .collect(); let system = System::new_with_specifics( - RefreshKind::new() - .with_processes(ProcessRefreshKind::new().with_cpu()), + RefreshKind::nothing().with_processes( + ProcessRefreshKind::nothing() + .with_cpu() + .with_exe(UpdateKind::OnlyIfNotSet), + ), ); let procs = parse_processes( @@ -909,14 +918,17 @@ fn main() { }) }) .filter(|process| { - if process.exe().is_file() { + if process.exe().is_some_and(Path::is_file) { true } else { eprintln!( "No valid executable found for process {} with ID {}: {}", - process.name(), + process.name().to_string_lossy(), process.pid(), - process.exe().display() + process + .exe() + .unwrap_or(Path::new("")) + .display() ); false } @@ -927,13 +939,16 @@ fn main() { print_process_results(&Processes::new(procs), &settings); } else if let Some(procname) = procname { let system = System::new_with_specifics( - RefreshKind::new() - .with_processes(ProcessRefreshKind::new().with_cpu()), + RefreshKind::nothing().with_processes( + ProcessRefreshKind::nothing() + .with_cpu() + .with_exe(UpdateKind::OnlyIfNotSet), + ), ); let procs = parse_processes( system - .processes_by_name(procname) + .processes_by_name(OsStr::new(procname)) // TODO: processes_by_name() should return a Iterator implementing the trait Send .collect::>() .into_iter(), From 5f4dac2468b998aa1aba034151ac028b7dcafec9 Mon Sep 17 00:00:00 2001 From: Brad Swain Date: Thu, 19 Feb 2026 13:08:37 -0600 Subject: [PATCH 2/3] Adapt to sysinfo 0.38 API and deduplicate RefreshKind --- checksec.rs/src/main.rs | 38 +++++++++++++------------------------- 1 file changed, 13 insertions(+), 25 deletions(-) diff --git a/checksec.rs/src/main.rs b/checksec.rs/src/main.rs index bab8f9c..9b76a07 100644 --- a/checksec.rs/src/main.rs +++ b/checksec.rs/src/main.rs @@ -877,14 +877,14 @@ fn main() { libraries, ); + let refresh_kind = RefreshKind::nothing().with_processes( + ProcessRefreshKind::nothing() + .with_cpu() + .with_exe(UpdateKind::OnlyIfNotSet), + ); + if procall { - let system = System::new_with_specifics( - RefreshKind::nothing().with_processes( - ProcessRefreshKind::nothing() - .with_cpu() - .with_exe(UpdateKind::OnlyIfNotSet), - ), - ); + let system = System::new_with_specifics(refresh_kind); let procs = parse_processes(system.processes().values(), libraries); @@ -900,13 +900,7 @@ fn main() { } }) .collect(); - let system = System::new_with_specifics( - RefreshKind::nothing().with_processes( - ProcessRefreshKind::nothing() - .with_cpu() - .with_exe(UpdateKind::OnlyIfNotSet), - ), - ); + let system = System::new_with_specifics(refresh_kind); let procs = parse_processes( procids @@ -925,10 +919,10 @@ fn main() { "No valid executable found for process {} with ID {}: {}", process.name().to_string_lossy(), process.pid(), - process - .exe() - .unwrap_or(Path::new("")) - .display() + match process.exe() { + Some(exe) => exe.display().to_string(), + None => "".to_string(), + } ); false } @@ -938,13 +932,7 @@ fn main() { print_process_results(&Processes::new(procs), &settings); } else if let Some(procname) = procname { - let system = System::new_with_specifics( - RefreshKind::nothing().with_processes( - ProcessRefreshKind::nothing() - .with_cpu() - .with_exe(UpdateKind::OnlyIfNotSet), - ), - ); + let system = System::new_with_specifics(refresh_kind); let procs = parse_processes( system From a5112f16f944774a4c23b40a31593f297c6b0a7d Mon Sep 17 00:00:00 2001 From: Brad Swain Date: Thu, 19 Feb 2026 13:53:59 -0600 Subject: [PATCH 3/3] minor fix --- checksec.rs/src/main.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/checksec.rs/src/main.rs b/checksec.rs/src/main.rs index 9b76a07..8b11611 100644 --- a/checksec.rs/src/main.rs +++ b/checksec.rs/src/main.rs @@ -707,9 +707,13 @@ where processes .par_bridge() .filter_map(|process| { - let exe = match process.exe() { - Some(exe) => exe, - None => return None, + let Some(exe) = process.exe() else { + eprintln!( + "No executable path for process {} with ID {}", + process.name().to_string_lossy(), + process.pid() + ); + return None; }; match parse(exe, &mut Some(Arc::clone(&cache))) { Err(err) => { @@ -878,9 +882,7 @@ fn main() { ); let refresh_kind = RefreshKind::nothing().with_processes( - ProcessRefreshKind::nothing() - .with_cpu() - .with_exe(UpdateKind::OnlyIfNotSet), + ProcessRefreshKind::nothing().with_cpu().with_exe(UpdateKind::Always), ); if procall {