Skip to content

Commit

Permalink
chore: merge imports
Browse files Browse the repository at this point in the history
  • Loading branch information
desbma-s1n committed Jun 3, 2024
1 parent c57daee commit bd6b6b5
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 45 deletions.
6 changes: 1 addition & 5 deletions src/strace/mod.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
3 changes: 1 addition & 2 deletions src/strace/parser/peg.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
3 changes: 1 addition & 2 deletions src/strace/parser/regex.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
10 changes: 6 additions & 4 deletions src/strace/run.rs
Original file line number Diff line number Diff line change
@@ -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 _;

Expand Down
19 changes: 12 additions & 7 deletions src/summarize.rs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
19 changes: 11 additions & 8 deletions src/systemd/options.rs
Original file line number Diff line number Diff line change
@@ -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)]
Expand Down
14 changes: 9 additions & 5 deletions src/systemd/resolver.rs
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -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<OptionDescription> {
let sd_version = SystemdVersion::new(254, 0);
Expand Down
18 changes: 10 additions & 8 deletions src/systemd/service.rs
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
5 changes: 1 addition & 4 deletions src/systemd/version.rs
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down

0 comments on commit bd6b6b5

Please sign in to comment.