diff --git a/src/detections/pivot.rs b/src/detections/pivot.rs index 845ded27..2f83c162 100644 --- a/src/detections/pivot.rs +++ b/src/detections/pivot.rs @@ -57,8 +57,8 @@ pub fn insert_pivot_keyword(event_record: &Value) { } else { return; } - let mut pivots = PIVOT_KEYWORD.write().unwrap().clone(); - for (_, pivot) in pivots.iter_mut() { + let mut pivots = PIVOT_KEYWORD.write().unwrap(); + pivots.iter_mut().into_iter().for_each(|(_, pivot)| { for field in &pivot.fields { if let Some(array_str) = configs::EVENTKEY_ALIAS.get_event_key(&String::from(field)) { let split: Vec<&str> = array_str.split('.').collect(); @@ -82,7 +82,7 @@ pub fn insert_pivot_keyword(event_record: &Value) { } } } - } + }); } #[cfg(test)] diff --git a/src/main.rs b/src/main.rs index aae3f64b..78b05eb1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -297,7 +297,8 @@ impl App { if *PIVOT_KEYWORD_LIST_FLAG { //ファイル出力の場合 if let Some(pivot_file) = configs::CONFIG.read().unwrap().args.value_of("output") { - for (key, pivot_keyword) in PIVOT_KEYWORD.read().unwrap().iter() { + let pivot_key_unions = PIVOT_KEYWORD.read().unwrap().clone(); + for (key, pivot_keyword) in pivot_key_unions.iter() { let mut f = BufWriter::new( fs::File::create(pivot_file.to_owned() + "-" + key + ".txt").unwrap(), ); @@ -321,7 +322,6 @@ impl App { //output to stdout let mut output = "Pivot keyword results saved to the following files:\n".to_string(); - let pivot_key_unions = PIVOT_KEYWORD.read().unwrap().clone(); for (key, _) in pivot_key_unions.iter() { output += &(pivot_file.to_owned() + "-" + key + ".txt" + "\n");