Skip to content

Commit

Permalink
Add: handle wrong plugin path error
Browse files Browse the repository at this point in the history
  • Loading branch information
jjnicola committed Nov 23, 2022
1 parent 18aaf2a commit 14a7ca0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions rust/nvtcache/src/dberror.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ pub enum DbError {
},
MaxDbErr(String),
NoAvailDbErr(String),
PluginDirErr {
path: String,
},
CustomErr(String),
}

Expand All @@ -25,6 +28,7 @@ impl fmt::Display for DbError {
} => write!(f, "Redis Error. {kind}: {source}. {detail}"),
DbError::MaxDbErr(e) => write!(f, "Error: {}", e),
DbError::NoAvailDbErr(e) => write!(f, "Error: {}", e),
DbError::PluginDirErr { path } => write!(f, "Invalid plugin path: {}", path),
DbError::CustomErr(e) => write!(f, "Error: {}", e),
}
}
Expand Down
7 changes: 7 additions & 0 deletions rust/nvtcache/src/nvtcache.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::dberror::DbError;
use crate::dberror::Result;
use crate::nvt::*;
use crate::redisconnector::*;
Expand All @@ -23,6 +24,12 @@ impl<'a> NvtCache<'a> {

let cache_key = "nvticache";

if !Path::new(plugin_path).exists() {
return Err(DbError::PluginDirErr {
path: plugin_path.to_string(),
});
}

Ok(NvtCache {
cache: rctx,
init: true,
Expand Down

0 comments on commit 14a7ca0

Please sign in to comment.