add comment

This commit is contained in:
ichiichi11
2021-05-15 01:39:43 +09:00
parent ff2bbcc1b8
commit 6e1e414e18
4 changed files with 23 additions and 18 deletions

View File

@@ -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<EvtxRecordInfo> ) {
pub fn start(&mut self, records: Vec<EvtxRecordInfo>) {
let rules = self.parse_rule_files();
if rules.is_empty() {
return;

View File

@@ -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") {

View File

@@ -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<String>を表示するコードは実装していません。
pub fn start(&mut self, _records: &Vec<EvtxRecordInfo> ) -> Vec<String> {
pub fn start(&mut self, _records: &Vec<EvtxRecordInfo>) -> Vec<String> {
// 引数で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![];
}
}
}

View File

@@ -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<EvtxRecordInfo> ) {
pub fn start(&mut self, records: &Vec<EvtxRecordInfo>) {
let mut statistic = EventStatistics::new();
statistic.start(records);
}
}
}