Skip to content

Commit

Permalink
Fix: scannerctl option name and redis-storage distaptcher (#1604)
Browse files Browse the repository at this point in the history
  • Loading branch information
jjnicola authored Mar 18, 2024
1 parent a4db006 commit 3da335c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
19 changes: 18 additions & 1 deletion rust/redis-storage/src/connector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,15 @@ impl RedisCtx {
self.release_namespace()?;
Ok(())
}

/// Clean up the namespace.
pub fn flush_namespace(&mut self) -> RedisStorageResult<()> {
Cmd::new()
.arg("FLUSHDB")
.query(&mut self.kb.as_mut().expect("Valid redis connection"))?;
Ok(())
}

//Wrapper function to avoid accessing kb member directly.
pub fn set_value<T: ToRedisArgs>(&mut self, key: &str, val: T) -> RedisStorageResult<()> {
self.kb
Expand Down Expand Up @@ -676,7 +685,7 @@ where
selector: &[NameSpaceSelector],
) -> RedisStorageResult<PerItemDispatcher<CacheDispatcher<RedisCtx, K>, K>> {
let cache = Self::init(redis_url, selector)?;
cache.reset()?;
cache.flushdb()?;
Ok(PerItemDispatcher::new(cache))
}

Expand All @@ -687,6 +696,14 @@ where
.map_err(|e| DbError::SystemError(format!("{e:?}")))?;
cache.delete_namespace()
}

/// Reset the NVT Cache. Do not release the namespace. Only ensure it is clean
pub fn flushdb(&self) -> RedisStorageResult<()> {
let mut cache = Arc::as_ref(&self.cache)
.lock()
.map_err(|e| DbError::SystemError(format!("{e:?}")))?;
cache.flush_namespace()
}
}

impl<S, K> storage::item::ItemDispatcher<K> for CacheDispatcher<S, K>
Expand Down
2 changes: 1 addition & 1 deletion rust/scannerctl/src/notusupdate/scanner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub fn extend_args(cmd: Command) -> Command {
.action(ArgAction::SetTrue),
)
.arg(
arg!(-l --pkg-list <STRING> "Comma separated list of packages.")
arg!(-l --"pkg-list" <STRING> "Comma separated list of packages.")
.required_unless_present("input"),
)
.arg(Arg::new("os").required(true).action(ArgAction::Append)),
Expand Down

0 comments on commit 3da335c

Please sign in to comment.