Skip to content

Commit

Permalink
Change: openvasctl library to openvas
Browse files Browse the repository at this point in the history
As the ctl suffix indicates that it is a cli program it is renamed to
openvas.
  • Loading branch information
nichtsfrei committed Mar 1, 2024
1 parent 51a03d6 commit 2842dcf
Show file tree
Hide file tree
Showing 19 changed files with 35 additions and 40 deletions.
4 changes: 2 additions & 2 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
Expand Up @@ -24,7 +24,7 @@ members = [
"feed-verifier",
"models",
"osp",
"openvasctl",
"openvas",
"openvasd",
"infisto",
"smoketest",
Expand Down
2 changes: 1 addition & 1 deletion rust/openvasctl/Cargo.toml → rust/openvas/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "openvasctl"
name = "openvas"
version = "0.1.0"
edition = "2021"

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions rust/openvasctl/src/lib.rs → rust/openvas/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ pub mod openvas_redis;
pub mod pref_handler;
pub mod result_collector;
pub mod openvas;
pub use openvas::Scanner;
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ mod tests {

let mut resh = ResultHelper::init(rc);

let _ = resh.process_results(results).unwrap();
resh.process_results(results).unwrap();

let single_r = Result {
id: 0,
Expand All @@ -269,8 +269,7 @@ mod tests {
.as_ref()
.lock()
.unwrap()
.results
.get(0)
.results.first()
.unwrap()
),
single_r
Expand Down Expand Up @@ -346,7 +345,7 @@ mod tests {
};

let resh = ResultHelper::init(rc);
let _ = resh.process_status(status).unwrap();
resh.process_status(status).unwrap();

let mut r = HashMap::new();
r.insert("127.0.0.1".to_string(), 12);
Expand Down
2 changes: 1 addition & 1 deletion rust/openvasd/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ storage = { path = "../storage" }
redis-storage = { path = "../redis-storage" }
infisto = { path = "../infisto" }
notus = { path = "../notus" }
openvasctl = { path = "../openvasctl" }
openvas = { path = "../openvas" }
hyper = { version = "1", features = ["full"] }
hyper-rustls = "0"
tokio = { version = "1.28.1", features = ["full"] }
Expand Down
8 changes: 4 additions & 4 deletions rust/openvasd/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ pub struct Scanner {
pub enum ScannerType {
#[serde(rename = "ospd")]
OSPD,
#[serde(rename = "openvasctl")]
Openvasctl,
#[serde(rename = "openvas")]
Openvas,
}

impl Default for ScannerType {
Expand All @@ -85,7 +85,7 @@ impl TypedValueParser for ScannerType {
) -> Result<Self::Value, clap::Error> {
Ok(match value.to_str().unwrap_or_default() {
"ospd" => ScannerType::OSPD,
"openvasctl" => ScannerType::Openvasctl,
"openvas" => ScannerType::Openvas,
_ => {
let mut cmd = cmd.clone();
let err = cmd.error(
Expand Down Expand Up @@ -390,7 +390,7 @@ impl Config {
clap::Arg::new("wrapper-type")
.env("WRAPPER_TYPE")
.long("wrapper-type")
.value_name("ospd,openvasctl")
.value_name("ospd,openvas")
.value_parser(ScannerType::OSPD)
.help("Type of wrapper used to manage scans")
)
Expand Down
2 changes: 1 addition & 1 deletion rust/openvasd/src/controller/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ impl<S>
impl<S, DB, T> ContextBuilder<S, DB, T> {
/// Sets the feed config.
pub fn feed_config(mut self, config: config::Feed) -> Self {
self.feed_config = Some(config.into());
self.feed_config = Some(config);
if let Some(fp) = self.feed_config.as_ref() {
let loader = nasl_interpreter::FSPluginLoader::new(fp.path.clone());
let dispatcher: DefaultDispatcher<String> = DefaultDispatcher::default();
Expand Down
20 changes: 10 additions & 10 deletions rust/openvasd/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ where
&config.notus.advisories_path,
),
scanner,
&config,
config,
);
controller::run(ctx, &config).await
controller::run(ctx, config).await
}
config::StorageType::InMemory => {
tracing::info!("using in memory store. No sensitive data will be stored on disk.");
Expand All @@ -99,9 +99,9 @@ where
&config.notus.advisories_path,
),
scanner,
&config,
config,
);
controller::run(ctx, &config).await
controller::run(ctx, config).await
}
config::StorageType::FileSystem => {
if let Some(key) = &config.storage.fs.key {
Expand All @@ -117,9 +117,9 @@ where
&config.notus.advisories_path,
)?,
scanner,
&config,
config,
);
controller::run(ctx, &config).await
controller::run(ctx, config).await
} else {
tracing::warn!(
"using in file storage. Sensitive data will be stored on disk without any encryption."
Expand All @@ -131,9 +131,9 @@ where
&config.notus.advisories_path,
)?,
scanner,
&config,
config,
);
controller::run(ctx, &config).await
controller::run(ctx, config).await
}
}
}
Expand Down Expand Up @@ -161,8 +161,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
)
.await
}
config::ScannerType::Openvasctl => {
run(openvasctl::openvas::Scanner::default(), &config).await
config::ScannerType::Openvas => {
run(openvas::Scanner::default(), &config).await
}
}
}
26 changes: 11 additions & 15 deletions rust/openvasd/src/scheduling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ pub enum Error {
/// Queue overseeds the configured maximal queue amount
QueueFull,
/// An error occured while using the Scanner
ScanError(ScanError),
Scan(ScanError),
/// An error occured while using the DB
StorageError(StorageError),
Storage(StorageError),
}

impl Display for Error {
Expand All @@ -37,8 +37,8 @@ impl Display for Error {
Error::ScanAlreadyQueued => write!(f, "scan is already queued"),
Error::NotFound => write!(f, "scan was not found"),
Error::QueueFull => write!(f, "unable to queue scan: queue is already full."),
Error::ScanError(e) => write!(f, "scan error occured: {}", e),
Error::StorageError(e) => write!(f, "storage error occured: {}", e),
Error::Scan(e) => write!(f, "scan error occured: {}", e),
Error::Storage(e) => write!(f, "storage error occured: {}", e),
}
}
}
Expand All @@ -47,23 +47,23 @@ impl std::error::Error for Error {}

impl From<ScanError> for Error {
fn from(value: ScanError) -> Self {
Self::ScanError(value)
Self::Scan(value)
}
}

impl From<StorageError> for Error {
fn from(value: StorageError) -> Self {
match value {
StorageError::NotFound => Self::NotFound,
value => Self::StorageError(value),
value => Self::Storage(value),
}
}
}

// yo, dawg I heard you like transforming
impl Into<ScanError> for Error {
fn into(self) -> ScanError {
ScanError::Unexpected(format!("{}", self))
impl From<Error> for ScanError {
fn from(val: Error) -> Self {
ScanError::Unexpected(format!("{}", val))
}
}
/// Scheduler is a core component of managing scans.
Expand Down Expand Up @@ -237,12 +237,8 @@ where
let results = self.handle_results();
let cr = coordination.await;
let rr = results.await;
if let Err(e) = cr {
return Err(e);
}
if let Err(e) = rr {
return Err(e);
}
cr?;
rr?;
Ok(())
}

Expand Down
1 change: 0 additions & 1 deletion rust/openvasd/src/storage/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,6 @@ mod tests {

for s in scans.clone().into_iter() {
let r = storage.get_scan(&s.scan_id).await;
dbg!(&r);
r.unwrap();
}
storage.remove_scan("5").await.unwrap();
Expand Down

0 comments on commit 2842dcf

Please sign in to comment.