Skip to content

Commit

Permalink
Change: rename scanner_preferences -> scan_preferences
Browse files Browse the repository at this point in the history
For backwards compatability, the alias scanner_preferences can still be used
  • Loading branch information
Kraemii committed Mar 28, 2024
1 parent 6addc38 commit 254bdfd
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 47 deletions.
19 changes: 8 additions & 11 deletions rust/doc/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand All @@ -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."
Expand Down Expand Up @@ -634,7 +634,7 @@ components:
- aes
- des

ScannerPreference:
ScanPreference:
description: "Consists of a preference ID and its value."
type: "object"
properties:
Expand Down Expand Up @@ -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":
[
{
Expand Down Expand Up @@ -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" },
Expand Down Expand Up @@ -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" },
Expand Down
55 changes: 26 additions & 29 deletions rust/doc/reverse-sensor-openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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."
Expand Down Expand Up @@ -396,7 +396,7 @@ components:
- aes
- des

ScannerPreference:
ScanPreference:
description: "Consists of a preference ID and its value."
type: "object"
properties:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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" },
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion rust/models/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ mod tests {
"reverse_lookup_unify": true,
"reverse_lookup_only": false
},
"scanner_preferences": [
"scan_preferences": [
{
"id": "target_port",
"value": "443"
Expand Down
9 changes: 6 additions & 3 deletions rust/models/src/scan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand All @@ -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<ScannerPreference>,
pub scan_preferences: Vec<ScanPreference>,
/// List of VTs to execute for the target
pub vts: Vec<VT>,
}
2 changes: 1 addition & 1 deletion rust/models/src/scanner_preference.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion rust/openvas/src/pref_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
1 change: 1 addition & 0 deletions rust/openvasd/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Empty file added rust/openvasd/src/preference.rs
Empty file.
2 changes: 1 addition & 1 deletion rust/osp/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)))?;
Expand Down

0 comments on commit 254bdfd

Please sign in to comment.