From 3552204378a17a181b1845a083268628dc7edf56 Mon Sep 17 00:00:00 2001 From: DustInDark Date: Wed, 15 Jun 2022 03:37:52 +0900 Subject: [PATCH] refactoring * statistics flag and logon-summary flag is static ref merged. * removed comment out code * fixed typo comment --- src/timeline/statistics.rs | 15 ++++----------- src/timeline/timelines.rs | 12 +++++------- 2 files changed, 9 insertions(+), 18 deletions(-) diff --git a/src/timeline/statistics.rs b/src/timeline/statistics.rs index ab9e60bf..3b743379 100644 --- a/src/timeline/statistics.rs +++ b/src/timeline/statistics.rs @@ -1,4 +1,5 @@ use crate::detections::{configs, detection::EvtxRecordInfo, utils}; +use crate::detections::print::{LOGONSUMMARY_FLAG, STATISTICS_FLAG}; use hashbrown::HashMap; #[derive(Debug)] @@ -34,11 +35,7 @@ impl EventStatistics { pub fn evt_stats_start(&mut self, records: &[EvtxRecordInfo]) { // 引数でstatisticsオプションが指定されている時だけ、統計情報を出力する。 - if !configs::CONFIG - .read() - .unwrap() - .args - .is_present("statistics") + if !*STATISTICS_FLAG { return; } @@ -53,12 +50,8 @@ impl EventStatistics { } pub fn logon_stats_start(&mut self, records: &[EvtxRecordInfo]) { - // 引数でstatisticsオプションが指定されている時だけ、統計情報を出力する。 - if !configs::CONFIG - .read() - .unwrap() - .args - .is_present("logon-summary") + // 引数でlogon-summaryオプションが指定されている時だけ、統計情報を出力する。 + if !*LOGONSUMMARY_FLAG { return; } diff --git a/src/timeline/timelines.rs b/src/timeline/timelines.rs index 6eb1025d..5a35205b 100644 --- a/src/timeline/timelines.rs +++ b/src/timeline/timelines.rs @@ -1,4 +1,5 @@ use crate::detections::{configs::CONFIG, detection::EvtxRecordInfo}; +use crate::detections::print::{LOGONSUMMARY_FLAG, STATISTICS_FLAG}; use prettytable::{Cell, Row, Table}; use super::statistics::EventStatistics; @@ -19,8 +20,8 @@ impl Timeline { pub fn new() -> Timeline { let totalcnt = 0; let filepath = String::default(); - let starttm = "".to_string(); - let endtm = "".to_string(); + let starttm = String::default(); + let endtm = String::default(); let statslst = HashMap::new(); let statsloginlst = HashMap::new(); @@ -35,12 +36,10 @@ impl Timeline { } pub fn tm_stats_dsp_msg(&mut self) { - let statics_flag = CONFIG.read().unwrap().args.is_present("statistics"); - if !statics_flag { + if !*STATISTICS_FLAG { return; } // 出力メッセージ作成 - //println!("map -> {:#?}", evtstat_map); let mut sammsges: Vec = Vec::new(); sammsges.push("---------------------------------------".to_string()); sammsges.push(format!("Evtx File Path: {}", self.stats.filepath)); @@ -66,8 +65,7 @@ impl Timeline { } pub fn tm_logon_stats_dsp_msg(&mut self) { - let logon_summary_flag = CONFIG.read().unwrap().args.is_present("logon-summary"); - if !logon_summary_flag { + if !*LOGONSUMMARY_FLAG { return; } // 出力メッセージ作成