Skip to content

Commit

Permalink
Merge pull request #9 from Yamato-Security/7-add-build-tests-to-githu…
Browse files Browse the repository at this point in the history
…b-actions

adjusted quick-xml update #7
  • Loading branch information
hitenkoku authored Oct 4, 2022
2 parents fc504d4 + 514f1e0 commit 5b0884d
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 99 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## [0.8.3 - 2022-10-04]

### Changed

- Update quick-xml to 0.24.1+ (@hitenkoku) (#7 #9)

## [0.8.1 - 2022-09-09]

### Changed
Expand Down
118 changes: 46 additions & 72 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ repository = "https://github.com/Yamato-Security/hayabusa-evtx"
license = "MIT"
readme = "README.md"

version = "0.8.2"
version = "0.8.3"
authors = ["Omer Ben-Amram <[email protected]>, Yamato Security"]
edition = "2021"

Expand All @@ -18,7 +18,7 @@ crc32fast = "1.*"
chrono = { version = "0.4", features = ["serde"] }
encoding = "0.2"
byteorder = "1.4"
quick-xml = "0.23"
quick-xml = "0.25.*"
thiserror = "1.0"
log = { version = "0.4", features = ["release_max_level_debug"] }
winstructs = "0.3"
Expand Down Expand Up @@ -52,9 +52,9 @@ evtx_dump = ["simplelog", "clap", "dialoguer", "indoc", "anyhow"]
multithreading = ["rayon"]

[dev-dependencies]
insta = { version = "1.19", features = ["json"] }
insta = { version = "1.21", features = ["json"] }
pretty_assertions = "1.*"
criterion = "0.3"
criterion = "0.4"
assert_cmd = "2.0"
predicates = "2.1"
env_logger = "0.9"
Expand Down
9 changes: 4 additions & 5 deletions src/binxml/name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,12 @@ impl BinXmlName {

impl<'a> From<&'a BinXmlName> for quick_xml::events::BytesStart<'a> {
fn from(name: &'a BinXmlName) -> Self {
BytesStart::borrowed_name(name.as_str().as_bytes())
BytesStart::new(name.as_str())
}
}

impl<'a> From<BinXmlName> for quick_xml::events::BytesEnd<'a> {
fn from(name: BinXmlName) -> Self {
let inner = name.as_str().as_bytes();
BytesEnd::owned(inner.to_vec())
impl<'a> From<&'a BinXmlName> for quick_xml::events::BytesEnd<'a> {
fn from(name: &'a BinXmlName) -> Self {
BytesEnd::new(name.as_str())
}
}
2 changes: 0 additions & 2 deletions src/evtx_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,6 @@ mod tests {
ensure_env_logger_initialized();
let evtx_file = include_bytes!("../samples/new-user-security.evtx");
let mut parser = EvtxParser::from_buffer(evtx_file.to_vec()).unwrap();

assert_eq!(parser.records().count(), 4);
}

Expand Down Expand Up @@ -703,7 +702,6 @@ mod tests {
ensure_env_logger_initialized();
let evtx_file = include_bytes!("../samples/new-user-security.evtx");
let parser = EvtxParser::from_buffer(evtx_file.to_vec()).unwrap();

assert_eq!(parser.into_chunks().count(), 1);
}

Expand Down
17 changes: 8 additions & 9 deletions src/json_output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -397,11 +397,10 @@ impl BinXmlOutput for JsonOutput {
// We also terminate the entity.
let entity_ref = "&".to_string() + entity.as_str() + ";";

let xml_event = BytesText::from_escaped_str(&entity_ref);
match xml_event.unescaped() {
let xml_event = BytesText::from_escaped(&entity_ref);
match xml_event.unescape() {
Ok(escaped) => {
let as_string = String::from_utf8(escaped.to_vec())
.expect("This cannot fail, since it was a valid string beforehand");
let as_string = escaped.to_string();

self.visit_characters(Cow::Owned(BinXmlValue::StringType(as_string)))?;
Ok(())
Expand Down Expand Up @@ -461,14 +460,16 @@ mod tests {
for attr in event.attributes() {
let attr = attr.expect("Failed to read attribute.");
attrs.push(XmlAttribute {
name: Cow::Owned(BinXmlName::from_string(bytes_to_string(attr.key))),
name: Cow::Owned(BinXmlName::from_string(bytes_to_string(attr.key.as_ref()))),
// We have to compromise here and assume all values are strings.
value: Cow::Owned(BinXmlValue::StringType(bytes_to_string(&attr.value))),
});
}

XmlElement {
name: Cow::Owned(BinXmlName::from_string(bytes_to_string(event.name()))),
name: Cow::Owned(BinXmlName::from_string(bytes_to_string(
event.name().as_ref(),
))),
attributes: attrs,
}
}
Expand All @@ -481,10 +482,8 @@ mod tests {
let mut output = JsonOutput::new(settings);
output.visit_start_of_stream().expect("Start of stream");

let mut buf = vec![];

loop {
match reader.read_event(&mut buf) {
match reader.read_event() {
Ok(event) => match event {
Event::Start(start) => {
output
Expand Down
Loading

0 comments on commit 5b0884d

Please sign in to comment.