From bd6b6b57ff270c2ec1b6dc5d86d770d8a353b427 Mon Sep 17 00:00:00 2001 From: desbma-s1n Date: Thu, 30 May 2024 18:51:16 +0200 Subject: [PATCH] chore: merge imports --- src/strace/mod.rs | 6 +----- src/strace/parser/peg.rs | 3 +-- src/strace/parser/regex.rs | 3 +-- src/strace/run.rs | 10 ++++++---- src/summarize.rs | 19 ++++++++++++------- src/systemd/options.rs | 19 +++++++++++-------- src/systemd/resolver.rs | 14 +++++++++----- src/systemd/service.rs | 18 ++++++++++-------- src/systemd/version.rs | 5 +---- 9 files changed, 52 insertions(+), 45 deletions(-) diff --git a/src/strace/mod.rs b/src/strace/mod.rs index 3319626..00cba9a 100644 --- a/src/strace/mod.rs +++ b/src/strace/mod.rs @@ -1,10 +1,6 @@ //! Strace related code -use std::collections::HashMap; -use std::fmt; -use std::io::BufRead; -use std::process::Command; -use std::str; +use std::{collections::HashMap, fmt, io::BufRead, process::Command, str}; mod parser; mod run; diff --git a/src/strace/parser/peg.rs b/src/strace/parser/peg.rs index 1c321e1..ec8e3c3 100644 --- a/src/strace/parser/peg.rs +++ b/src/strace/parser/peg.rs @@ -1,8 +1,7 @@ //! PEG based strace output parser use itertools::Itertools; -use pest::iterators::Pair; -use pest::Parser as _; +use pest::{iterators::Pair, Parser as _}; use crate::strace::{ BufferExpression, BufferType, Expression, IntegerExpression, IntegerExpressionValue, Syscall, diff --git a/src/strace/parser/regex.rs b/src/strace/parser/regex.rs index 3ab09ad..5c6382f 100644 --- a/src/strace/parser/regex.rs +++ b/src/strace/parser/regex.rs @@ -1,7 +1,6 @@ //! Regex based strace output parser -use std::collections::HashMap; -use std::str; +use std::{collections::HashMap, str}; use lazy_static::lazy_static; diff --git a/src/strace/run.rs b/src/strace/run.rs index dac7bce..e610601 100644 --- a/src/strace/run.rs +++ b/src/strace/run.rs @@ -1,9 +1,11 @@ //! Strace invocation code -use std::fs::File; -use std::io::BufReader; -use std::path::PathBuf; -use std::process::{Child, Command, Stdio}; +use std::{ + fs::File, + io::BufReader, + path::PathBuf, + process::{Child, Command, Stdio}, +}; use anyhow::Context as _; diff --git a/src/summarize.rs b/src/summarize.rs index 8696342..f30cc1d 100644 --- a/src/summarize.rs +++ b/src/summarize.rs @@ -1,16 +1,21 @@ //! Summarize program syscalls into higher level action -use std::collections::{HashMap, HashSet}; -use std::ffi::OsStr; -use std::os::unix::ffi::OsStrExt; -use std::path::{Path, PathBuf}; +use std::{ + collections::{HashMap, HashSet}, + ffi::OsStr, + os::unix::ffi::OsStrExt, + path::{Path, PathBuf}, +}; use lazy_static::lazy_static; -use crate::strace::{ - BufferExpression, BufferType, Expression, IntegerExpression, IntegerExpressionValue, Syscall, +use crate::{ + strace::{ + BufferExpression, BufferType, Expression, IntegerExpression, IntegerExpressionValue, + Syscall, + }, + systemd::{SocketFamily, SocketProtocol}, }; -use crate::systemd::{SocketFamily, SocketProtocol}; /// A high level program runtime action /// This does *not* map 1-1 with a syscall, and does *not* necessarily respect chronology diff --git a/src/systemd/options.rs b/src/systemd/options.rs index a411652..14c168d 100644 --- a/src/systemd/options.rs +++ b/src/systemd/options.rs @@ -1,18 +1,21 @@ //! Systemd option model -use std::collections::{HashMap, HashSet}; -use std::fmt; -use std::iter; -use std::os::unix::ffi::OsStrExt; -use std::path::{Path, PathBuf}; -use std::str::FromStr; +use std::{ + collections::{HashMap, HashSet}, + fmt, iter, + os::unix::ffi::OsStrExt, + path::{Path, PathBuf}, + str::FromStr, +}; use itertools::Itertools; use lazy_static::lazy_static; use strum::IntoEnumIterator; -use crate::cl::HardeningMode; -use crate::systemd::{KernelVersion, SystemdVersion}; +use crate::{ + cl::HardeningMode, + systemd::{KernelVersion, SystemdVersion}, +}; /// Systemd option with its possibles values, and their effect #[derive(Debug)] diff --git a/src/systemd/resolver.rs b/src/systemd/resolver.rs index 1e1bf72..6343c6b 100644 --- a/src/systemd/resolver.rs +++ b/src/systemd/resolver.rs @@ -1,8 +1,10 @@ //! Resolver code that finds options compatible with program actions -use crate::summarize::ProgramAction; -use crate::systemd::options::{ - ListMode, OptionDescription, OptionEffect, OptionValue, OptionValueEffect, OptionWithValue, +use crate::{ + summarize::ProgramAction, + systemd::options::{ + ListMode, OptionDescription, OptionEffect, OptionValue, OptionValueEffect, OptionWithValue, + }, }; impl OptionValueEffect { @@ -149,8 +151,10 @@ pub fn resolve( mod tests { use super::*; - use crate::cl::HardeningMode; - use crate::systemd::{build_options, KernelVersion, SystemdVersion}; + use crate::{ + cl::HardeningMode, + systemd::{build_options, KernelVersion, SystemdVersion}, + }; fn test_options(names: &[&str]) -> Vec { let sd_version = SystemdVersion::new(254, 0); diff --git a/src/systemd/service.rs b/src/systemd/service.rs index 3e2e4b6..f51ea85 100644 --- a/src/systemd/service.rs +++ b/src/systemd/service.rs @@ -1,17 +1,19 @@ //! Systemd service actions -use std::env; -use std::fs::{self, File}; -use std::io::{BufRead, BufReader, BufWriter, Write}; -use std::path::{Path, PathBuf}; -use std::process::{Command, Stdio}; +use std::{ + env, + fs::{self, File}, + io::{BufRead, BufReader, BufWriter, Write}, + path::{Path, PathBuf}, + process::{Command, Stdio}, +}; use itertools::Itertools; use rand::Rng; -use crate::cl::HardeningMode; -use crate::systemd::{ - options::OptionWithValue, END_OPTION_OUTPUT_SNIPPET, START_OPTION_OUTPUT_SNIPPET, +use crate::{ + cl::HardeningMode, + systemd::{options::OptionWithValue, END_OPTION_OUTPUT_SNIPPET, START_OPTION_OUTPUT_SNIPPET}, }; pub struct Service { diff --git a/src/systemd/version.rs b/src/systemd/version.rs index 253bbb8..b134f8f 100644 --- a/src/systemd/version.rs +++ b/src/systemd/version.rs @@ -1,9 +1,6 @@ //! Systemd & kernel version -use std::fmt; -use std::io::BufRead; -use std::process::Command; -use std::str; +use std::{fmt, io::BufRead, process::Command, str}; #[derive(Debug, Ord, PartialOrd, Eq, PartialEq)] pub struct SystemdVersion {