Feature/except hidden file#335 (#339)
* added except hidden file load #335 * fixed except hidden file in collect evtx #335
This commit is contained in:
22
src/main.rs
22
src/main.rs
@@ -19,6 +19,7 @@ use hhmmss::Hhmmss;
|
||||
use pbr::ProgressBar;
|
||||
use serde_json::Value;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::ffi::OsStr;
|
||||
use std::fmt::Display;
|
||||
use std::io::BufWriter;
|
||||
use std::path::Path;
|
||||
@@ -99,10 +100,18 @@ impl App {
|
||||
println!("");
|
||||
}
|
||||
if let Some(filepath) = configs::CONFIG.read().unwrap().args.value_of("filepath") {
|
||||
if !filepath.ends_with(".evtx") {
|
||||
if !filepath.ends_with(".evtx")
|
||||
|| Path::new(filepath)
|
||||
.file_stem()
|
||||
.unwrap_or(OsStr::new("."))
|
||||
.to_str()
|
||||
.unwrap()
|
||||
.trim()
|
||||
.starts_with(".")
|
||||
{
|
||||
AlertMessage::alert(
|
||||
&mut BufWriter::new(std::io::stderr().lock()),
|
||||
&"--filepath only accepts .evtx files.".to_string(),
|
||||
&"--filepath only accepts .evtx files. no hidden file.".to_string(),
|
||||
)
|
||||
.ok();
|
||||
return;
|
||||
@@ -171,7 +180,14 @@ impl App {
|
||||
});
|
||||
} else {
|
||||
let path_str = path.to_str().unwrap_or("");
|
||||
if path_str.ends_with(".evtx") {
|
||||
if path_str.ends_with(".evtx")
|
||||
&& !Path::new(path_str)
|
||||
.file_stem()
|
||||
.unwrap_or(OsStr::new("."))
|
||||
.to_str()
|
||||
.unwrap()
|
||||
.starts_with(".")
|
||||
{
|
||||
ret.push(path);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user