diff --git a/rust/doc/openapi.yml b/rust/doc/openapi.yml index 87c8e59070..01d43d47ac 100644 --- a/rust/doc/openapi.yml +++ b/rust/doc/openapi.yml @@ -414,11 +414,11 @@ components: properties: target: $ref: "#/components/schemas/Target" - scanner_preferences: + scan_preferences: description: "Overwrite the default settings of the Scanner." type: "array" items: - $ref: "#/components/schemas/ScannerPreference" + $ref: "#/components/schemas/ScanPreference" vts: type: "array" description: "A collection of VTs, which are run for the given target." @@ -445,11 +445,11 @@ components: $ref: "#/components/schemas/ScanID" target: $ref: "#/components/schemas/Target" - scanner_preferences: + scan_preferences: description: "Overwrite the default settings of the Scanner." type: "array" items: - $ref: "#/components/schemas/ScannerPreference" + $ref: "#/components/schemas/ScanPreference" vts: type: "array" description: "A collection of VTs, which are run for the given target." @@ -634,7 +634,7 @@ components: - aes - des - ScannerPreference: + ScanPreference: description: "Consists of a preference ID and its value." type: "object" properties: @@ -897,10 +897,7 @@ components: "2002::1234:abcd:ffff:c0a8:101/64", "examplehost", ], - "excluded_hosts": - [ - "192.168.0.14" - ], + "excluded_hosts": ["192.168.0.14"], "ports": [ { @@ -949,7 +946,7 @@ components: "reverse_lookup_unify": true, "reverse_lookup_only": false, }, - "scanner_preferences": + "scan_preferences": [ { "id": "target_port", "value": "443" }, { "id": "use_https", "value": "1" }, @@ -1030,7 +1027,7 @@ components: "reverse_lookup_unify": true, "reverse_lookup_only": false, }, - "scanner_preferences": + "scan_preferences": [ { "id": "target_port", "value": "443" }, { "id": "use_https", "value": "1" }, diff --git a/rust/doc/reverse-sensor-openapi.yml b/rust/doc/reverse-sensor-openapi.yml index 98b2245c94..58a14b149d 100644 --- a/rust/doc/reverse-sensor-openapi.yml +++ b/rust/doc/reverse-sensor-openapi.yml @@ -152,22 +152,22 @@ paths: parameters: - $ref: "#/components/parameters/ScanID" requestBody: - description: "The new status" - content: - application/json: + description: "The new status" + content: + application/json: + schema: + $ref: "#/components/schemas/Status" + examples: schema: - $ref: "#/components/schemas/Status" - examples: - schema: - description: "Schema of a status response." - status of a stored scan: - $ref: "#/components/examples/scan_status_stored" - status of a running scan: - $ref: "#/components/examples/scan_status_running" - status of a succeeded scan: - $ref: "#/components/examples/scan_status_success" - status of a failed scan: - $ref: "#/components/examples/scan_status_fail" + description: "Schema of a status response." + status of a stored scan: + $ref: "#/components/examples/scan_status_stored" + status of a running scan: + $ref: "#/components/examples/scan_status_running" + status of a succeeded scan: + $ref: "#/components/examples/scan_status_success" + status of a failed scan: + $ref: "#/components/examples/scan_status_fail" responses: "204": description: "Status received" @@ -228,11 +228,11 @@ components: $ref: "#/components/schemas/ScanID" target: $ref: "#/components/schemas/Target" - scanner_preferences: + scan_preferences: description: "Overwrite the default settings of the Scanner." type: "array" items: - $ref: "#/components/schemas/ScannerPreference" + $ref: "#/components/schemas/ScanPreference" vts: type: "array" description: "A collection of VTs, which are run for the given target." @@ -396,7 +396,7 @@ components: - aes - des - ScannerPreference: + ScanPreference: description: "Consists of a preference ID and its value." type: "object" properties: @@ -573,14 +573,10 @@ components: items: $ref: "#/components/schemas/ScanAction" - examples: sensor_simple: description: "A simple example for sensor." - value: - { - "sensor_id": "6c591f83-8f7b-452a-8c78-ba35779e682f" - } + value: { "sensor_id": "6c591f83-8f7b-452a-8c78-ba35779e682f" } scan_simple: description: "A simple example for creating a scan." value: @@ -656,7 +652,7 @@ components: "reverse_lookup_unify": true, "reverse_lookup_only": false, }, - "scanner_preferences": + "scan_preferences": [ { "id": "target_port", "value": "443" }, { "id": "use_https", "value": "1" }, @@ -677,19 +673,20 @@ components: value: "6c591f83-8f7b-452a-8c78-ba35779e682f" scan_actions: description: "Actions to perform" - value: [ + value: + [ { "scan_id": "6c591f83-8f7b-452a-8c78-ba35779e682f", - "action": "start" + "action": "start", }, { "scan_id": "24591f83-8f7b-452a-8c78-ba35779e6816", - "action": "stop" + "action": "stop", }, { "scan_id": "13591f83-8f74-45da-8c7d-ba35779e682a", - "action": "delete" - } + "action": "delete", + }, ] scan_results: diff --git a/rust/models/src/lib.rs b/rust/models/src/lib.rs index 6c4eec8a64..aecb0a6337 100644 --- a/rust/models/src/lib.rs +++ b/rust/models/src/lib.rs @@ -137,7 +137,7 @@ mod tests { "reverse_lookup_unify": true, "reverse_lookup_only": false }, - "scanner_preferences": [ + "scan_preferences": [ { "id": "target_port", "value": "443" diff --git a/rust/models/src/scan.rs b/rust/models/src/scan.rs index ce5283330c..98fb0fe17a 100644 --- a/rust/models/src/scan.rs +++ b/rust/models/src/scan.rs @@ -2,7 +2,7 @@ // // SPDX-License-Identifier: GPL-2.0-or-later -use super::{scanner_preference::ScannerPreference, target::Target, vt::VT}; +use super::{scanner_preference::ScanPreference, target::Target, vt::VT}; /// Struct for creating and getting a scan #[derive(Default, Debug, Clone, PartialEq, Eq)] @@ -17,9 +17,12 @@ pub struct Scan { pub scan_id: String, /// Information about the target to scan pub target: Target, - #[cfg_attr(feature = "serde_support", serde(default))] + #[cfg_attr( + feature = "serde_support", + serde(default, alias = "scanner_preferences") + )] /// Configuration options for the scanner - pub scanner_preferences: Vec, + pub scan_preferences: Vec, /// List of VTs to execute for the target pub vts: Vec, } diff --git a/rust/models/src/scanner_preference.rs b/rust/models/src/scanner_preference.rs index 5e1a461b28..a763049a0a 100644 --- a/rust/models/src/scanner_preference.rs +++ b/rust/models/src/scanner_preference.rs @@ -8,7 +8,7 @@ feature = "serde_support", derive(serde::Serialize, serde::Deserialize) )] -pub struct ScannerPreference { +pub struct ScanPreference { /// The ID of the scanner preference. pub id: String, /// The value of the scanner preference. diff --git a/rust/openvas/src/pref_handler.rs b/rust/openvas/src/pref_handler.rs index 12a6cb2a9d..27534bd805 100644 --- a/rust/openvas/src/pref_handler.rs +++ b/rust/openvas/src/pref_handler.rs @@ -339,7 +339,7 @@ where async fn prepare_scan_params_for_openvas(&mut self) -> RedisStorageResult<()> { let options = self .scan_config - .scanner_preferences + .scan_preferences .clone() .iter() .map(|x| format!("{}|||{}", x.id, x.value)) diff --git a/rust/openvasd/src/main.rs b/rust/openvasd/src/main.rs index 4e03064f01..b396acb6d3 100644 --- a/rust/openvasd/src/main.rs +++ b/rust/openvasd/src/main.rs @@ -13,6 +13,7 @@ pub mod controller; pub mod crypt; pub mod feed; pub mod notus; +pub mod preference; pub mod request; pub mod response; mod scheduling; diff --git a/rust/openvasd/src/preference.rs b/rust/openvasd/src/preference.rs new file mode 100644 index 0000000000..e69de29bb2 diff --git a/rust/osp/src/commands.rs b/rust/osp/src/commands.rs index 9a7c9c7e56..d9c09bcf4e 100644 --- a/rust/osp/src/commands.rs +++ b/rust/osp/src/commands.rs @@ -185,7 +185,7 @@ fn write_vts(scan: &Scan, writer: &mut Writer) -> Result<()> { // it is called scanner parameters. fn write_scanner_prefs(scan: &Scan, writer: &mut Writer) -> Result<()> { writer.write_event(Event::Start(BytesStart::new("scanner_params")))?; - for p in &scan.scanner_preferences { + for p in &scan.scan_preferences { writer.write_event(Event::Start(BytesStart::new(&p.id)))?; writer.write_event(Event::Text(BytesText::new(&p.value)))?; writer.write_event(Event::End(BytesEnd::new(&p.id)))?;