diff --git a/rust/infisto/src/base.rs b/rust/infisto/src/base.rs index 4bb3146357..3fc241ad98 100644 --- a/rust/infisto/src/base.rs +++ b/rust/infisto/src/base.rs @@ -403,7 +403,10 @@ impl Range { impl CachedIndexFileStorer { /// Initializes the storage. - pub fn init(base: &str) -> Result { + pub fn init

(base: P) -> Result + where + P: AsRef, + { let base = IndexedFileStorer::init(base)?; let cache = [None, None, None, None, None]; Ok(Self { base, cache }) diff --git a/rust/models/src/result.rs b/rust/models/src/result.rs index 4a5c59e583..5834aea742 100644 --- a/rust/models/src/result.rs +++ b/rust/models/src/result.rs @@ -12,6 +12,7 @@ use super::port::Protocol; feature = "serde_support", derive(serde::Serialize, serde::Deserialize) )] +#[cfg_attr(feature = "bincode_support", derive(bincode::Encode, bincode::Decode))] pub struct Result { /// Incremental ID of a result pub id: usize, @@ -78,6 +79,7 @@ impl> From<(usize, T)> for Result { derive(serde::Serialize, serde::Deserialize) )] #[cfg_attr(feature = "serde_support", serde(rename_all = "snake_case"))] +#[cfg_attr(feature = "bincode_support", derive(bincode::Encode, bincode::Decode))] pub enum ResultType { /// Vulnerability Alarm, diff --git a/rust/openvasd/src/storage/file.rs b/rust/openvasd/src/storage/file.rs index 1a34767fd7..3f614815c2 100644 --- a/rust/openvasd/src/storage/file.rs +++ b/rust/openvasd/src/storage/file.rs @@ -170,7 +170,7 @@ where id: &str, (status, results): FetchResult, ) -> Result<(), Error> { - let key = format!("results_{}", id); + let key = format!("results_{id}"); self.update_status(id, status).await?; let scan_key = format!("scan_{id}"); @@ -201,13 +201,17 @@ where let id = scan.scan_id.clone().unwrap_or_default(); let key = format!("scan_{id}"); let status_key = format!("status_{id}"); + let results_key = format!("results_{id}"); let storage = Arc::clone(&self.storage); tokio::task::spawn_blocking(move || { let scan = infisto::bincode::Serialization::serialize(scan)?; let status = infisto::bincode::Serialization::serialize(models::Status::default())?; + let results = + infisto::bincode::Serialization::serialize(Vec::::default())?; let mut storage = storage.write().unwrap(); storage.put(&key, scan)?; storage.put(&status_key, status)?; + storage.put(&results_key, results)?; let stored_key = infisto::bincode::Serialization::serialize(&id)?; storage.append("scans", stored_key)?;