Merge branch 'feature/code_refactor'

This commit is contained in:
akiranishikawa
2020-09-29 20:09:39 +09:00
4 changed files with 51 additions and 66 deletions

View File

@@ -8,7 +8,6 @@ use crate::models::event;
use evtx::EvtxParser; use evtx::EvtxParser;
use quick_xml::de::DeError; use quick_xml::de::DeError;
use std::collections::BTreeMap; use std::collections::BTreeMap;
use std::collections::HashMap;
#[derive(Debug)] #[derive(Debug)]
pub struct Detection { pub struct Detection {

View File

@@ -42,10 +42,9 @@ impl Security {
// Special privileges assigned to new logon (possible admin access) // Special privileges assigned to new logon (possible admin access)
// //
fn se_debug_privilege(&mut self, event_data: HashMap<String, String>) { fn se_debug_privilege(&mut self, event_data: HashMap<String, String>) {
match event_data.get("PrivilegeList") {
Some(privileage_list) => { if let Some(privileage_list) = event_data.get("PrivilegeList") {
match privileage_list.find("SeDebugPrivilege") { if let Some(_data) = privileage_list.find("SeDebugPrivilege") {
Some(_data) => {
// alert_all_adminが有効であれば、標準出力して知らせる // alert_all_adminが有効であれば、標準出力して知らせる
// DeepBlueCLIでは必ず0になっていて、基本的には表示されない。 // DeepBlueCLIでは必ず0になっていて、基本的には表示されない。
if self.alert_all_admin == 1 { if self.alert_all_admin == 1 {
@@ -88,10 +87,6 @@ impl Security {
} }
} }
} }
None => (),
}
}
None => (),
} }
} }
} }

View File

@@ -4,7 +4,7 @@ extern crate serde;
use clap::{App, AppSettings, Arg}; use clap::{App, AppSettings, Arg};
use evtx::EvtxParser; use evtx::EvtxParser;
use quick_xml::de::DeError; use quick_xml::de::DeError;
use std::{env, path::PathBuf, process}; use std::{path::PathBuf, process};
use yamato_event_analyzer::detections::detection; use yamato_event_analyzer::detections::detection;
fn build_app() -> clap::App<'static, 'static> { fn build_app() -> clap::App<'static, 'static> {
@@ -38,9 +38,8 @@ fn main() -> Result<(), DeError> {
let args = build_app().get_matches(); let args = build_app().get_matches();
let filepath: Option<&str> = args.value_of("filepath"); let filepath: Option<&str> = args.value_of("filepath");
match filepath { if let Some(filepath) = filepath {
Some(filepath) => parse_file(filepath), parse_file(filepath);
None => (),
} }
Ok(()) Ok(())

View File

@@ -85,12 +85,11 @@ impl Evtx {
// 文字列データを取得する // 文字列データを取得する
// //
fn get_string(v: &Data) -> String { fn get_string(v: &Data) -> String {
match &v.text { let mut ret = "".to_string();
Some(text) => { if let Some(text) = &v.text {
return text.to_string(); ret = text.to_string();
}
_ => return "".to_string(),
} }
return ret;
} }
// //
@@ -99,22 +98,15 @@ impl Evtx {
pub fn parse_event_data(&self) -> HashMap<String, String> { pub fn parse_event_data(&self) -> HashMap<String, String> {
let mut values = HashMap::new(); let mut values = HashMap::new();
match &self.event_data { if let Some(event_data) = &self.event_data {
Some(event_data) => match &event_data.data { if let Some(data) = &event_data.data {
Some(data) => {
for v in data.iter() { for v in data.iter() {
match &v.name { if let Some(name) = &v.name {
Some(name) => {
values.insert(name.to_string(), Evtx::get_string(v)); values.insert(name.to_string(), Evtx::get_string(v));
} }
None => (),
} }
} }
} }
None => (),
},
None => (),
}
values values
} }