diff --git a/src/detections/pivot.rs b/src/detections/pivot.rs index 2f83c162..040ab57e 100644 --- a/src/detections/pivot.rs +++ b/src/detections/pivot.rs @@ -7,7 +7,7 @@ use std::sync::RwLock; use crate::detections::configs; use crate::detections::utils::get_serde_number_to_string; -#[derive(Debug, Clone)] +#[derive(Debug)] pub struct PivotKeyword { pub keywords: HashSet, pub fields: HashSet, diff --git a/src/detections/print.rs b/src/detections/print.rs index 0f83b02e..5d5d6b43 100644 --- a/src/detections/print.rs +++ b/src/detections/print.rs @@ -252,10 +252,10 @@ impl AlertMessage { .as_bytes(), ) .ok(); - let error_logs = ERROR_LOG_STACK.lock().unwrap().clone(); - for error_log in error_logs.iter() { + let error_logs = ERROR_LOG_STACK.lock().unwrap(); + error_logs.iter().for_each(|error_log| { writeln!(error_log_writer, "{}", error_log).ok(); - } + }); println!( "Errors were generated. Please check {} for details.", *ERROR_LOG_PATH diff --git a/src/main.rs b/src/main.rs index 78b05eb1..fcc0bd31 100644 --- a/src/main.rs +++ b/src/main.rs @@ -152,8 +152,8 @@ impl App { } if let Some(csv_path) = configs::CONFIG.read().unwrap().args.value_of("output") { - let pivot_key_unions = PIVOT_KEYWORD.read().unwrap().clone(); - for (key, _) in pivot_key_unions.iter() { + let pivot_key_unions = PIVOT_KEYWORD.read().unwrap(); + pivot_key_unions.iter().for_each(|(key, _)| { let keywords_file_name = csv_path.to_owned() + "-" + key + ".txt"; if Path::new(&keywords_file_name).exists() { AlertMessage::alert(&format!( @@ -163,7 +163,7 @@ impl App { .ok(); return; } - } + }); if Path::new(csv_path).exists() { AlertMessage::alert(&format!( " The file {} already exists. Please specify a different filename.", @@ -297,8 +297,8 @@ impl App { if *PIVOT_KEYWORD_LIST_FLAG { //ファイル出力の場合 if let Some(pivot_file) = configs::CONFIG.read().unwrap().args.value_of("output") { - let pivot_key_unions = PIVOT_KEYWORD.read().unwrap().clone(); - for (key, pivot_keyword) in pivot_key_unions.iter() { + let pivot_key_unions = PIVOT_KEYWORD.read().unwrap(); + pivot_key_unions.iter().for_each(|(key, pivot_keyword)| { let mut f = BufWriter::new( fs::File::create(pivot_file.to_owned() + "-" + key + ".txt").unwrap(), ); @@ -317,7 +317,7 @@ impl App { } f.write_all(output.as_bytes()).unwrap(); - } + }); //output to stdout let mut output = @@ -330,8 +330,8 @@ impl App { } else { //標準出力の場合 let mut output = "The following pivot keywords were found:\n".to_string(); - let pivot_key_unions = PIVOT_KEYWORD.read().unwrap().clone(); - for (key, pivot_keyword) in pivot_key_unions.iter() { + let pivot_key_unions = PIVOT_KEYWORD.read().unwrap(); + pivot_key_unions.iter().for_each(|(key, pivot_keyword)| { output += &format!("{}: ", key).to_string(); output += "( "; @@ -346,7 +346,7 @@ impl App { } output += "\n"; - } + }); write_color_buffer(BufferWriter::stdout(ColorChoice::Always), None, &output).ok(); } }