Merge pull request #59 from YamatoSecurity/feature/issue#57

Feature/issue#57
This commit is contained in:
ichiichi
2021-02-27 11:15:29 +09:00
committed by GitHub
3 changed files with 13 additions and 19 deletions

View File

@@ -85,14 +85,12 @@ fn test_emit_csv() {
"CommandLine": "hoge"
},
"System": {
"TimeCreated": {
"#attributes":{
"TimeCreated_attributes": {
"SystemTime": "1996-02-27T01:05:01Z"
}
}
}
}
}
"##;
let event: Value = serde_json::from_str(val).unwrap();
messages.insert(&event, "test".to_string(), "pokepoke".to_string());

View File

@@ -5,7 +5,7 @@ use crate::detections::rule;
use crate::detections::rule::RuleNode;
use crate::yaml::ParseYaml;
use evtx::err;
use evtx::{EvtxParser, SerializedEvtxRecord};
use evtx::{EvtxParser, ParserSettings, SerializedEvtxRecord};
use serde_json::{Error, Value};
use std::path::PathBuf;
@@ -66,6 +66,9 @@ impl Detection {
}
})
.map(|mut cur| {
let mut parse_config = ParserSettings::default();
parse_config = parse_config.separate_json_attributes(true);
cur = cur.with_configuration(parse_config);
let ret: Vec<err::Result<SerializedEvtxRecord<String>>> =
cur.records_json().collect();
return ret;

View File

@@ -120,8 +120,7 @@ impl Message {
}
fn get_event_time(event_record: &Value) -> Option<DateTime<Utc>> {
let system_time =
&event_record["Event"]["System"]["TimeCreated"]["#attributes"]["SystemTime"];
let system_time = &event_record["Event"]["System"]["TimeCreated_attributes"]["SystemTime"];
let system_time_str = system_time.as_str().unwrap_or("");
if system_time_str.is_empty() {
return Option::None;
@@ -157,14 +156,12 @@ mod tests {
"CommandLine": "hoge"
},
"System": {
"TimeCreated": {
"#attributes":{
"TimeCreated_attributes": {
"SystemTime": "1996-02-27T01:05:01Z"
}
}
}
}
}
"##;
let event_record_1: Value = serde_json::from_str(json_str_1).unwrap();
message.insert(
@@ -180,14 +177,12 @@ mod tests {
"CommandLine": "hoge"
},
"System": {
"TimeCreated": {
"#attributes":{
"TimeCreated_attributes": {
"SystemTime": "1996-02-27T01:05:01Z"
}
}
}
}
}
"##;
let event_record_2: Value = serde_json::from_str(json_str_2).unwrap();
message.insert(
@@ -203,14 +198,12 @@ mod tests {
"CommandLine": "hoge"
},
"System": {
"TimeCreated": {
"#attributes":{
"TimeCreated_attributes": {
"SystemTime": "2000-01-21T09:06:01Z"
}
}
}
}
}
"##;
let event_record_3: Value = serde_json::from_str(json_str_3).unwrap();
message.insert(