Feature/change output timeformat#154 (#194)

* changed default output time format #154

* added time zone #154

* added rfc3339 option #154
This commit is contained in:
DustInDark
2021-11-14 17:48:38 +09:00
committed by GitHub
parent 50aebce32e
commit 480f2d26c0
2 changed files with 8 additions and 2 deletions

View File

@@ -118,8 +118,10 @@ where
{
if configs::CONFIG.read().unwrap().args.is_present("rfc-2822") {
return time.to_rfc2822();
} else {
} else if configs::CONFIG.read().unwrap().args.is_present("rfc-3339") {
return time.to_rfc3339();
} else {
return time.format("%Y-%m-%d %H:%M:%S%.3f %:z").to_string();
}
}
@@ -169,7 +171,10 @@ fn test_emit_csv() {
.unwrap();
let expect_tz = expect_time.with_timezone(&Local);
let expect = "Time,Filepath,Rulepath,Level,Computername,Eventid,Alert,Details\n".to_string()
+ &expect_tz.clone().format("%Y-%m-%dT%H:%M:%S%:z").to_string()
+ &expect_tz
.clone()
.format("%Y-%m-%d %H:%M:%S%.3f %:z")
.to_string()
+ ","
+ &testfilepath.replace(".evtx", "").to_string()
+ ","

View File

@@ -50,6 +50,7 @@ fn build_app<'a>() -> ArgMatches<'a> {
let usages = "-f --filepath=[FILEPATH] 'Event file path'
--csv-timeline=[CSV_TIMELINE] 'Csv output timeline'
--rfc-2822 'Output date and time in RFC 2822 format. Example: Mon, 07 Aug 2006 12:34:56 -0600'
--rfc-3339 'Output date and time in RFC 3339 format. Example: 2006-08-07T12:34:56.485214 -06:00'
-l --lang=[LANG] 'Output language'
-L --level=[LEVEL] 'Specified execute rule level(default: INFO)'
-u --utc 'Output time in UTC format(default: local time)'