refactoring

* statistics flag and logon-summary flag is static ref merged.
* removed comment out code
* fixed typo comment
This commit is contained in:
DustInDark
2022-06-15 03:37:52 +09:00
parent 62397032e2
commit 3552204378
2 changed files with 9 additions and 18 deletions

View File

@@ -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;
}

View File

@@ -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<String> = 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;
}
// 出力メッセージ作成