diff --git a/src/afterfact.rs b/src/afterfact.rs index 5f7dff25..9d83f8c2 100644 --- a/src/afterfact.rs +++ b/src/afterfact.rs @@ -228,7 +228,8 @@ fn emit_csv( let mut timestamps: Vec = Vec::new(); let mut plus_header = true; let mut detected_record_idset: HashSet = HashSet::new(); - for (time, detect_infos) in messages.iter() { + let detect_union = messages.iter(); + for (time, detect_infos) in detect_union { timestamps.push(_get_timestamp(time)); for detect_info in detect_infos { detected_record_idset.insert(format!("{}_{}", time, detect_info.eventid)); @@ -429,7 +430,7 @@ fn _get_serialized_disp_output(dispformat: Option) -> String { /// return str position in output file fn _format_cellpos(colval: &str, column: ColPos) -> String { - return match column { + match column { ColPos::First => format!("{} ", colval), ColPos::Last => format!(" {}", colval), ColPos::Other => format!(" {} ", colval), diff --git a/src/detections/pivot.rs b/src/detections/pivot.rs index f8be1801..24f6ad69 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; } - - for (_, pivot) in PIVOT_KEYWORD.write().unwrap().iter_mut() { + let mut pivots = PIVOT_KEYWORD.write().unwrap().iter_mut(); + for (_, pivot) in pivots { 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(); diff --git a/src/detections/print.rs b/src/detections/print.rs index 6d4433f3..c7288369 100644 --- a/src/detections/print.rs +++ b/src/detections/print.rs @@ -252,7 +252,8 @@ impl AlertMessage { .as_bytes(), ) .ok(); - for error_log in ERROR_LOG_STACK.lock().unwrap().iter() { + let error_logs = ERROR_LOG_STACK.lock().unwrap().iter(); + for error_log in error_logs { writeln!(error_log_writer, "{}", error_log).ok(); } println!( diff --git a/src/detections/rule/matchers.rs b/src/detections/rule/matchers.rs index 744b45a0..5ed1a8c8 100644 --- a/src/detections/rule/matchers.rs +++ b/src/detections/rule/matchers.rs @@ -483,7 +483,7 @@ impl PipeElement { wildcard_regex_value.to_string() }; - return format!("{}{}", acc, regex_value); + format!("{}{}", acc, regex_value) }, ); diff --git a/src/detections/utils.rs b/src/detections/utils.rs index bfad4c46..4dc2fed9 100644 --- a/src/detections/utils.rs +++ b/src/detections/utils.rs @@ -276,7 +276,7 @@ fn create_recordinfos(record: &Value) -> String { let summary: Vec = output .iter() .map(|(key, value)| { - return format!("{}:{}", key, value); + format!("{}:{}", key, value) }) .collect(); @@ -314,7 +314,7 @@ fn _collect_recordinfo<'a>( continue; } // Event.Systemは出力しない - if key.eq("System") && keys.get(0).unwrap_or(&"").eq(&"Event") { + if key.eq("System") && keys.first().unwrap_or(&"").eq(&"Event") { continue; } diff --git a/src/timeline/timelines.rs b/src/timeline/timelines.rs index 20e1ea77..420aaf8b 100644 --- a/src/timeline/timelines.rs +++ b/src/timeline/timelines.rs @@ -35,11 +35,12 @@ impl Timeline { } pub fn tm_stats_dsp_msg(&mut self) { - if !configs::CONFIG - .read() - .unwrap() - .args - .is_present("statistics") + let statics_flag = configs::CONFIG + .read() + .unwrap() + .args + .is_present("statistics"); + if ! statics_flag { return; } @@ -70,11 +71,12 @@ impl Timeline { } pub fn tm_logon_stats_dsp_msg(&mut self) { - if !configs::CONFIG - .read() - .unwrap() - .args - .is_present("logon-summary") + let logon_summary_flag = configs::CONFIG + .read() + .unwrap() + .args + .is_present("logon-summary"); + if !logon_summary_flag { return; }