From cf939b88e3923829cab27780bfda7f3e8b7a2da3 Mon Sep 17 00:00:00 2001 From: puffyCid <16283453+puffyCid@users.noreply.github.com> Date: Thu, 21 Nov 2024 23:10:43 -0500 Subject: [PATCH 1/2] protobf parsing support --- src/unified_log.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/unified_log.rs b/src/unified_log.rs index c93892e..301efa4 100755 --- a/src/unified_log.rs +++ b/src/unified_log.rs @@ -24,12 +24,13 @@ use crate::header::HeaderChunk; use crate::message::format_firehose_log_message; use crate::preamble::LogPreamble; use crate::timesync::TimesyncBoot; -use crate::util::{extract_string, padding_size, unixepoch_to_iso}; +use crate::util::{encode_standard, extract_string, padding_size, unixepoch_to_iso}; use crate::uuidtext::UUIDText; use log::{error, warn}; use nom::bytes::complete::take; use regex::Regex; use serde::Serialize; +use sunlight::light::extract_protobuf; #[derive(Debug, Clone)] pub struct UnifiedLogData { @@ -537,7 +538,17 @@ impl Iterator for LogIterator<'_> { let data_string = match statedump.unknown_data_type { 0x1 => Statedump::parse_statedump_plist(&statedump.statedump_data), - 0x2 => String::from("Statedump Protocol Buffer"), + 0x2 => { + let result = extract_protobuf(&statedump.statedump_data); + match result { + Ok(map) => serde_json::to_string(&map) + .unwrap_or(String::from("Failed to serialize Protobuf HashMap")), + Err(_err) => format!( + "Failed to parse StateDump protobuf: {}", + encode_standard(&statedump.statedump_data) + ), + } + } 0x3 => Statedump::parse_statedump_object( &statedump.statedump_data, &statedump.title_name, From 2fd4440a4c9f1f933e0b0ae36cecedabc24f04a9 Mon Sep 17 00:00:00 2001 From: puffyCid <16283453+puffyCid@users.noreply.github.com> Date: Thu, 21 Nov 2024 23:53:45 -0500 Subject: [PATCH 2/2] added sunlight dependency --- Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Cargo.toml b/Cargo.toml index b29356e..ac6d3df 100755 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,6 +16,7 @@ plist = "1.7.0" regex = "1.10.6" base64 = "0.22.1" chrono = "0.4.38" +sunlight = "0.1.0" [dev-dependencies] simplelog = "0.12.2"