Skip to content

Commit e643f44

Browse files
Kraemiitehforsch
authored andcommitted
Fix: Scan Preference handling
There were multiple issues with the scan preference handling: 1. All given values for preferences of type checkbox (bool) were yes, if they were not set to `0`. With the fix the values `0`, `false` and `no` will lead to a false and the values `1`, `true` and `yes` will lead to a true. All other values are invalid and logged. In this case VT parameters are skipped and Scan Preferences fall back to their default. 2. Configured scan preferences via the command line or config file were ignored when a scan was created. They were correctly set into the config, but never read. In the end just the default values were used 3. Alive Test preference 7 value was always set to `yes` All things are fixed now and tests were created.
1 parent 3b5d4db commit e643f44

6 files changed

Lines changed: 478 additions & 139 deletions

File tree

‎rust/src/openvas/openvas.rs‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use super::{
1111
result_collector::ResultHelper,
1212
};
1313
use crate::models::{self, HostInfo, Phase, Scan, Status};
14+
use crate::scanner::preferences::preference::ScanPrefValue;
1415
use tokio::process::Child;
1516

1617
use crate::storage::redis::{NameSpaceSelector, RedisCtx};
@@ -30,7 +31,7 @@ pub struct OpenvasScanner {
3031
sudo: bool,
3132
redis_socket: String,
3233
resource_checker: Option<Checker>,
33-
default_scanner_preferences: Vec<models::ScanPreferenceInformation>,
34+
default_scanner_preferences: HashMap<String, ScanPrefValue>,
3435
}
3536
use crate::scanner::{Error as ScanError, ScanResultKind, ScanResults, Scanner};
3637

@@ -94,7 +95,7 @@ impl OpenvasScanner {
9495
cpu: Option<f32>,
9596
sudo: bool,
9697
url: String,
97-
default_scanner_preferences: Vec<models::ScanPreferenceInformation>,
98+
default_scanner_preferences: HashMap<String, ScanPrefValue>,
9899
) -> Self {
99100
Self {
100101
running: Default::default(),
@@ -105,6 +106,10 @@ impl OpenvasScanner {
105106
}
106107
}
107108

109+
pub fn scan_preferences(&self) -> &HashMap<String, ScanPrefValue> {
110+
&self.default_scanner_preferences
111+
}
112+
108113
/// Removes a scan from init and add it to the list of running scans
109114
async fn add_running(&self, id: String, dbid: u32) -> Result<bool, OpenvasError> {
110115
let openvas = cmd::start(&id, self.sudo, None).map_err(OpenvasError::CmdError)?;

0 commit comments

Comments
 (0)