From bc9bc7831819da284d6c3866655ccd5d2e13378d Mon Sep 17 00:00:00 2001 From: KCarretto Date: Wed, 21 Feb 2024 21:22:33 +0000 Subject: [PATCH] fix display for message --- implants/imix/src/install.rs | 3 +-- implants/imix/src/task.rs | 2 +- implants/lib/eldritch/src/file/read_impl.rs | 4 +-- .../lib/eldritch/src/runtime/messages/mod.rs | 27 +++++++++---------- 4 files changed, 16 insertions(+), 20 deletions(-) diff --git a/implants/imix/src/install.rs b/implants/imix/src/install.rs index 7cf0801ad..f0d614d8c 100644 --- a/implants/imix/src/install.rs +++ b/implants/imix/src/install.rs @@ -1,7 +1,6 @@ use anyhow::{anyhow, Result}; -use eldritch::runtime::Message; use pb::eldritch::Tome; -use std::{collections::HashMap, fmt::Write}; +use std::collections::HashMap; pub async fn install() { #[cfg(debug_assertions)] diff --git a/implants/imix/src/task.rs b/implants/imix/src/task.rs index 53769edc7..d5dc30f55 100644 --- a/implants/imix/src/task.rs +++ b/implants/imix/src/task.rs @@ -1,6 +1,6 @@ use anyhow::Result; use eldritch::runtime::messages::Dispatcher; -use pb::c2::{ReportTaskOutputRequest, Task, TaskError, TaskOutput}; +use pb::c2::{ReportTaskOutputRequest, TaskError, TaskOutput}; use transport::Transport; /* diff --git a/implants/lib/eldritch/src/file/read_impl.rs b/implants/lib/eldritch/src/file/read_impl.rs index 6e8673eaa..52728ba9b 100644 --- a/implants/lib/eldritch/src/file/read_impl.rs +++ b/implants/lib/eldritch/src/file/read_impl.rs @@ -18,9 +18,9 @@ pub fn read(path: String) -> Result { let data = fs::read_to_string(entry_path)?; res.push_str(data.as_str()); } - Err(local_err) => { + Err(_err) => { #[cfg(debug_assertions)] - log::debug!("Failed to parse glob {}\n{}", path, local_err); + log::debug!("Failed to parse glob {}\n{}", path, _err); } } } diff --git a/implants/lib/eldritch/src/runtime/messages/mod.rs b/implants/lib/eldritch/src/runtime/messages/mod.rs index cf14d4f4c..3e60ec0e1 100644 --- a/implants/lib/eldritch/src/runtime/messages/mod.rs +++ b/implants/lib/eldritch/src/runtime/messages/mod.rs @@ -21,13 +21,10 @@ pub use report_text::ReportTextMessage; pub use transport::Transport; use anyhow::Result; -use derive_more::From; +use derive_more::{Display, From}; use report_agg_output::ReportAggOutputMessage; use std::future::Future; -#[cfg(debug_assertions)] -use derive_more::Display; - // Dispatcher defines the shared "dispatch" method used by all `Message` variants to send their data using a transport. pub trait Dispatcher { fn dispatch(self, transport: &mut impl Transport) -> impl Future> + Send; @@ -38,34 +35,34 @@ pub trait Dispatcher { * This enables eldritch library functions to communicate with the caller API, enabling structured data reporting * as well as resource requests (e.g. fetching assets). */ -#[cfg_attr(debug_assertions, derive(Debug, Display, PartialEq))] -#[derive(From, Clone)] +#[cfg_attr(debug_assertions, derive(Debug, PartialEq))] +#[derive(Display, From, Clone)] pub enum Message { - #[cfg_attr(debug_assertions, display(fmt = "FetchAsset"))] + #[display(fmt = "FetchAsset")] FetchAsset(FetchAssetMessage), - #[cfg_attr(debug_assertions, display(fmt = "ReportCredential"))] + #[display(fmt = "ReportCredential")] ReportCredential(ReportCredentialMessage), - #[cfg_attr(debug_assertions, display(fmt = "ReportError"))] + #[display(fmt = "ReportError")] ReportError(ReportErrorMessage), - #[cfg_attr(debug_assertions, display(fmt = "ReportFile"))] + #[display(fmt = "ReportFile")] ReportFile(ReportFileMessage), - #[cfg_attr(debug_assertions, display(fmt = "ReportProcessList"))] + #[display(fmt = "ReportProcessList")] ReportProcessList(ReportProcessListMessage), - #[cfg_attr(debug_assertions, display(fmt = "ReportText"))] + #[display(fmt = "ReportText")] ReportText(ReportTextMessage), - #[cfg_attr(debug_assertions, display(fmt = "ReportStart"))] + #[display(fmt = "ReportStart")] ReportStart(ReportStartMessage), - #[cfg_attr(debug_assertions, display(fmt = "ReportFinish"))] + #[display(fmt = "ReportFinish")] ReportFinish(ReportFinishMessage), - #[cfg_attr(debug_assertions, display(fmt = "ReportAggOutput"))] + #[display(fmt = "ReportAggOutput")] ReportAggOutput(ReportAggOutputMessage), }