Skip to content

Commit

Permalink
Add nvtcache lib
Browse files Browse the repository at this point in the history
  • Loading branch information
jjnicola committed Nov 23, 2022
1 parent 85ed440 commit bf07a27
Show file tree
Hide file tree
Showing 10 changed files with 526 additions and 5 deletions.
135 changes: 131 additions & 4 deletions rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion rust/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[workspace]
members = ["nasl-syntax", "nasl-cli"]
members = ["nasl-syntax", "nasl-cli", "nvtcache"]
130 changes: 130 additions & 0 deletions rust/nvtcache/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions rust/nvtcache/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[package]
name = "nvtcache"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
redis = "0.22.1"
3 changes: 3 additions & 0 deletions rust/nvtcache/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# NVTCache

Libary for initializing and loading up the NVT Cache for OpenVAS Scanner written in rust.
39 changes: 39 additions & 0 deletions rust/nvtcache/src/dberror.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
use redis::*;
use std::error;
use std::fmt;

pub mod dberror {
use super::*;

pub type Result<T> = std::result::Result<T, DbError>;

#[derive(Debug)]
pub enum DbError {
RedisErr(RedisError),
CustomErr(String),
}

impl fmt::Display for DbError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match &*self {
DbError::RedisErr(..) => write!(f, "Redis Error"),
DbError::CustomErr(e) => write!(f, "Error: String Message {}", e),
}
}
}

impl error::Error for DbError {
fn source(&self) -> Option<&(dyn error::Error + 'static)> {
match *self {
DbError::RedisErr(ref e) => Some(e),
DbError::CustomErr(_) => None,
}
}
}

impl From<RedisError> for DbError {
fn from(err: RedisError) -> DbError {
DbError::RedisErr(err)
}
}
}
3 changes: 3 additions & 0 deletions rust/nvtcache/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pub mod dberror;
pub mod nvtcache;
pub mod redisconnector;
Loading

0 comments on commit bf07a27

Please sign in to comment.