Skip to content

Commit

Permalink
fix: load unknown was not handled correctly in file reader
Browse files Browse the repository at this point in the history
  • Loading branch information
alexkornitzer committed Jul 5, 2022
1 parent dac08f1 commit 7fbfbf0
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/file/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,19 @@ impl Reader {
}),
_ => {
if load_unknown {
if let Ok(parser) = EvtxParser::load(file) {
return Ok(Self {
parser: Parser::Evtx(parser),
});
} else if let Ok(parser) = JsonParser::load(file) {
return Ok(Self {
parser: Parser::Json(parser),
});
} else if let Ok(parser) = XmlParser::load(file) {
return Ok(Self {
parser: Parser::Xml(parser),
});
}
if skip_errors {
cs_eyellowln!(
"file type is not currently supported - {}",
Expand All @@ -98,7 +111,7 @@ impl Reader {
})
} else {
anyhow::bail!(
"file type is not currently supported - {}, use --skip-errors to continue",
"file type is not currently supported - {}, use --skip-errors to continue...",
file.display()
)
}
Expand Down Expand Up @@ -126,12 +139,14 @@ impl Reader {
}
if skip_errors {
cs_eyellowln!("file type is not known - {}", file.display());

Ok(Self {
parser: Parser::Unknown,
})
} else {
anyhow::bail!("file type is not known - {}", file.display())
anyhow::bail!(
"file type is not known - {}, use --skip-errors to continue...",
file.display()
)
}
} else {
Ok(Self {
Expand Down

0 comments on commit 7fbfbf0

Please sign in to comment.