From 6e1e414e181ecf54b9c184c8bf231ffd4d92cbe7 Mon Sep 17 00:00:00 2001 From: ichiichi11 Date: Sat, 15 May 2021 01:39:43 +0900 Subject: [PATCH] add comment --- src/detections/detection.rs | 13 ++++++------- src/main.rs | 2 +- src/timeline/statistics.rs | 18 +++++++++++++----- src/timeline/timeline.rs | 8 +++----- 4 files changed, 23 insertions(+), 18 deletions(-) diff --git a/src/detections/detection.rs b/src/detections/detection.rs index 7228ffbb..d657c22c 100644 --- a/src/detections/detection.rs +++ b/src/detections/detection.rs @@ -9,7 +9,7 @@ use crate::detections::rule::RuleNode; use crate::detections::{print::AlertMessage, utils}; use crate::yaml::ParseYaml; -use std::{sync::Arc}; +use std::sync::Arc; const DIRPATH_RULES: &str = "rules"; @@ -21,25 +21,24 @@ pub struct EvtxRecordInfo { } impl EvtxRecordInfo { - pub fn new(evtx_filepath:String, record: Value) -> EvtxRecordInfo{ - return EvtxRecordInfo{ + pub fn new(evtx_filepath: String, record: Value) -> EvtxRecordInfo { + return EvtxRecordInfo { evtx_filepath: evtx_filepath, - record: record + record: record, }; } } // TODO テストケースかかなきゃ... #[derive(Debug)] -pub struct Detection { -} +pub struct Detection {} impl Detection { pub fn new() -> Detection { return Detection {}; } - pub fn start(&mut self, records: Vec ) { + pub fn start(&mut self, records: Vec) { let rules = self.parse_rule_files(); if rules.is_empty() { return; diff --git a/src/main.rs b/src/main.rs index 93126867..ade1ad82 100644 --- a/src/main.rs +++ b/src/main.rs @@ -7,12 +7,12 @@ use std::{ path::PathBuf, }; use tokio::{spawn, task::JoinHandle}; -use yamato_event_analyzer::{detections::configs, timeline::timeline::Timeline}; use yamato_event_analyzer::detections::detection; use yamato_event_analyzer::detections::detection::EvtxRecordInfo; use yamato_event_analyzer::detections::print::AlertMessage; use yamato_event_analyzer::omikuji::Omikuji; use yamato_event_analyzer::{afterfact::after_fact, detections::utils}; +use yamato_event_analyzer::{detections::configs, timeline::timeline::Timeline}; fn main() { if let Some(filepath) = configs::CONFIG.read().unwrap().args.value_of("filepath") { diff --git a/src/timeline/statistics.rs b/src/timeline/statistics.rs index c73051fc..f0cfe1c1 100644 --- a/src/timeline/statistics.rs +++ b/src/timeline/statistics.rs @@ -1,8 +1,7 @@ use crate::detections::{configs, detection::EvtxRecordInfo}; #[derive(Debug)] -pub struct EventStatistics { -} +pub struct EventStatistics {} /** * Windows Event Logの統計情報を出力する */ @@ -13,11 +12,20 @@ impl EventStatistics { // この関数の戻り値として、コンソールに出力する内容をStringの可変配列(Vec)として返却してください。 // 可変配列にしているのは改行を表すためで、可変配列にコンソールに出力する内容を1行ずつ追加してください。 + // 引数の_recordsが読み込んだWindowsイベントログのを表す、EvtxRecordInfo構造体の配列になっています。 + // EvtxRecordInfo構造体の pub record: Value というメンバーがいて、それがWindowsイベントログの1レコード分を表していますので、 + // EvtxRecordInfo構造体のrecordから、EventIDとか統計情報を取得するようにしてください。 + // recordからEventIDを取得するには、detection::utils::get_event_value()という関数があるので、それを使うと便利かもしれません。 // 現状では、この関数の戻り値として返すVecを表示するコードは実装していません。 - pub fn start(&mut self, _records: &Vec ) -> Vec { + pub fn start(&mut self, _records: &Vec) -> Vec { // 引数でstatisticsオプションが指定されている時だけ、統計情報を出力する。 - if !configs::CONFIG.read().unwrap().args.is_present("statistics") { + if !configs::CONFIG + .read() + .unwrap() + .args + .is_present("statistics") + { return vec![]; } @@ -25,4 +33,4 @@ impl EventStatistics { return vec![]; } -} \ No newline at end of file +} diff --git a/src/timeline/timeline.rs b/src/timeline/timeline.rs index 47294d1f..1ac008d6 100644 --- a/src/timeline/timeline.rs +++ b/src/timeline/timeline.rs @@ -2,18 +2,16 @@ use crate::detections::detection::EvtxRecordInfo; use super::statistics::EventStatistics; - #[derive(Debug)] -pub struct Timeline { -} +pub struct Timeline {} impl Timeline { pub fn new() -> Timeline { return Timeline {}; } - pub fn start(&mut self, records: &Vec ) { + pub fn start(&mut self, records: &Vec) { let mut statistic = EventStatistics::new(); statistic.start(records); } -} \ No newline at end of file +}