Skip to content

Commit e5a8101

Browse files
committed
Add: Notus address configuration
In preparation for the notus migration to skiron, this adds a config to use an external API to get notus results.
1 parent c6987f4 commit e5a8101

File tree

4 files changed

+17
-1
lines changed

4 files changed

+17
-1
lines changed

rust/examples/openvasd/config.example.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ check_interval = "3600s"
1818
products_path = "/var/lib/notus/products/"
1919
# path to the notus advisories feed. This is required for the /vts endpoint
2020
advisories_path = "/var/lib/notus/advisories/"
21+
# Address to reach notus on. If not set, internal notus implementation is used.
22+
# address = "127.0.0.1:3001"
2123

2224
[endpoints]
2325
# Enables GET /scans endpoint
@@ -102,4 +104,3 @@ max_scanning = 10
102104
batch_size = 2
103105
# How long openvasd should pause before retrying
104106
retry_timeout = "1s"
105-

rust/src/openvasd/config/mod.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ pub struct Feed {
3636
pub struct Notus {
3737
pub products_path: PathBuf,
3838
pub advisories_path: PathBuf,
39+
pub address: Option<SocketAddr>,
3940
}
4041

4142
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
@@ -139,6 +140,7 @@ impl Default for Notus {
139140
Notus {
140141
products_path: PathBuf::from("/var/lib/notus/products"),
141142
advisories_path: PathBuf::from("/var/lib/notus/advisories"),
143+
address: None,
142144
}
143145
}
144146
}
@@ -437,6 +439,14 @@ impl Config {
437439
.value_parser(clap::builder::PathBufValueParser::new())
438440
.action(ArgAction::Set)
439441
.help("Path containing the Notus products directory"))
442+
.arg(
443+
clap::Arg::new("notus-address")
444+
.env("NOTUS_ADDRESS")
445+
.long("notus-address")
446+
.value_name("IP:PORT")
447+
.value_parser(clap::value_parser!(SocketAddr))
448+
.action(ArgAction::Set)
449+
.help("the address to reach notus on"))
440450
.arg(
441451
clap::Arg::new("redis-url")
442452
.long("redis-url")
@@ -658,6 +668,9 @@ impl Config {
658668
if let Some(path) = cmds.get_one::<PathBuf>("notus-advisories") {
659669
config.notus.advisories_path.clone_from(path);
660670
}
671+
if let Some(address) = cmds.get_one::<SocketAddr>("notus-address") {
672+
config.notus.address = Some(*address);
673+
}
661674
if let Some(_path) = cmds.get_one::<String>("redis-url") {
662675
// is actually ignored as on scanner openvas the redis-url of openvas is used
663676
}

rust/src/openvasd/notus/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ mod tests {
162162
let notus = crate::config::Notus {
163163
advisories_path,
164164
products_path,
165+
address: None,
165166
};
166167

167168
Config {

rust/src/openvasd/scans/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,7 @@ pub mod tests {
511511
let notus = crate::config::Notus {
512512
advisories_path,
513513
products_path,
514+
address: None,
514515
};
515516
let scanner = crate::config::Scanner {
516517
scanner_type: crate::config::ScannerType::Openvasd,

0 commit comments

Comments
 (0)