Skip to content

Commit

Permalink
Fix: add redis to the storage options for clap
Browse files Browse the repository at this point in the history
  • Loading branch information
nichtsfrei committed Apr 8, 2024
1 parent fc30c99 commit 5c18918
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions rust/openvasd/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ impl TypedValueParser for ScannerType {
let mut cmd = cmd.clone();
let err = cmd.error(
clap::error::ErrorKind::InvalidValue,
"`{}` is not a wrapper type.",
"`{}` is not a scanner type.",
);
return Err(err);
}
Expand Down Expand Up @@ -161,7 +161,7 @@ impl Default for Listener {
pub enum Mode {
#[default]
#[serde(rename = "service")]
/// Enables all endpoints and moniors feed and active scans.
/// Enables all endpoints and monitors feed and active scans.
Service,
/// Disables everything but the notus endpoints
#[serde(rename = "service_notus")]
Expand All @@ -184,7 +184,7 @@ impl TypedValueParser for Mode {
let mut cmd = cmd.clone();
let err = cmd.error(
clap::error::ErrorKind::InvalidValue,
"`{}` is not a wrapper type.",
"`{}` is not a scanner type.",
);
return Err(err);
}
Expand Down Expand Up @@ -243,11 +243,12 @@ impl TypedValueParser for StorageType {
Ok(match value.to_str().unwrap_or_default() {
"fs" => StorageType::FileSystem,
"inmemory" => StorageType::InMemory,
_ => {
"redis" => StorageType::Redis,
x => {
let mut cmd = cmd.clone();
let err = cmd.error(
clap::error::ErrorKind::InvalidValue,
"`{}` is not a storage type.",
format!("`{x}` is not a storage type."),
);
return Err(err);
}
Expand Down Expand Up @@ -428,12 +429,12 @@ impl Config {
.help("API key that must be set as X-API-KEY header to gain access"),
)
.arg(
clap::Arg::new("wrapper-type")
.env("WRAPPER_TYPE")
.long("wrapper-type")
clap::Arg::new("scanner-type")
.env("SCANNER_TYPE")
.long("scanner-type")
.value_name("ospd,openvas")
.value_parser(ScannerType::OSPD)
.help("Type of wrapper used to manage scans")
.help("Type of scanner used to manage scans")
)
.arg(
clap::Arg::new("max-queued-scans")
Expand Down Expand Up @@ -501,8 +502,8 @@ impl Config {
clap::Arg::new("storage_type")
.env("STORAGE_TYPE")
.long("storage-type")
.value_name("fs,inmemory")
.value_parser(StorageType::InMemory)
.value_name("redis,inmemory,fs")
.help("either be stored in memory or on the filesystem."),
)
.arg(
Expand Down Expand Up @@ -549,8 +550,8 @@ impl Config {
if let Some(interval) = cmds.get_one::<u64>("feed-check-interval") {
config.feed.check_interval = Duration::from_secs(*interval);
}
if let Some(wrapper_type) = cmds.get_one::<ScannerType>("wrapper-type") {
config.scanner.scanner_type = wrapper_type.clone()
if let Some(scanner_type) = cmds.get_one::<ScannerType>("scanner-type") {
config.scanner.scanner_type = scanner_type.clone()
}
if let Some(max_queued_scans) = cmds.get_one::<usize>("max-queued-scans") {
config.scheduler.max_queued_scans = Some(*max_queued_scans)
Expand Down

0 comments on commit 5c18918

Please sign in to comment.