Skip to content

Commit

Permalink
Fix: add the nvt after the checks calling the recently added redis_ad…
Browse files Browse the repository at this point in the history
…d_nvt().

Also, small fix name in a function and add a function wrapper for getting an Nvt item
  • Loading branch information
jjnicola committed Nov 23, 2022
1 parent 26f065c commit ef1e910
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion rust/nvtcache/src/nvtcache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,21 @@ impl NvtCache {
Ok(false)
}

pub fn get_nvt_field(&mut self, oid: String, field: KbNvtPos) -> Result<String> {
let mut key: String = "nvt:".to_owned();
key.push_str(oid.as_str());
let value = self.cache.redis_get_item(key, field)?;
Ok(value)
}

pub fn get_nvt_filename(&mut self, oid: &String) -> Result<String> {
let mut key: String = "nvt:".to_owned();
key.push_str(oid);
let filename = self.cache.redis_get_item(key, KbNvtPos::NvtFilenamePos)?;
Ok(filename)
}

pub fn add_ntv(&mut self, mut nvt: Nvt, filename: String) -> Result<()> {
pub fn add_nvt(&mut self, mut nvt: Nvt, filename: String) -> Result<()> {
let oid = nvt.get_oid()?;
let cached_nvt: String = self.get_nvt_filename(&oid)?;

Expand All @@ -90,6 +97,7 @@ impl NvtCache {
let _ = self.cache.redis_del_key(key)?;
}

self.cache.redis_add_nvt(nvt, filename)?;
Ok(())
}
}

0 comments on commit ef1e910

Please sign in to comment.