From a45daaefcb52370601278806ad9b0a27db875ed5 Mon Sep 17 00:00:00 2001 From: Javier Parada Date: Sun, 15 Dec 2024 10:46:30 +0100 Subject: [PATCH] add create breach command --- .../create_one/create_breach_command.rs | 92 +++++++++++++++++++ .../breaches/application/create_one/mod.rs | 1 + 2 files changed, 93 insertions(+) create mode 100644 libs/cti/src/breaches/application/create_one/create_breach_command.rs diff --git a/libs/cti/src/breaches/application/create_one/create_breach_command.rs b/libs/cti/src/breaches/application/create_one/create_breach_command.rs new file mode 100644 index 0000000..3875b69 --- /dev/null +++ b/libs/cti/src/breaches/application/create_one/create_breach_command.rs @@ -0,0 +1,92 @@ +use cqrs::domain::command::Command; + +pub struct CreateBreachCommand { + pub id: Option, + + pub vendor: Option, + pub product: Option, + pub product_version: Option, + pub product_type: Option, + + pub cve_id: Option, + pub cve_state: Option, + pub cve_description: Option, + pub cve_assigner_id: Option, + pub cve_assigner_name: Option, + pub cve_date_published: Option, + pub cve_date_updated: Option, +} + +impl CreateBreachCommand { + pub const COMMAND_TYPE: &'static str = "com.tanukibox.cti.cves.create-one@1.0.0"; + + pub fn new( + id: Option, + vendor: Option, + product: Option, + product_version: Option, + product_type: Option, + cve_id: Option, + cve_state: Option, + cve_description: Option, + cve_assigner_id: Option, + cve_assigner_name: Option, + cve_date_published: Option, + cve_date_updated: Option, + ) -> CreateBreachCommand { + CreateBreachCommand { + id, + vendor, + product, + product_version, + product_type, + cve_id, + cve_state, + cve_description, + cve_assigner_id, + cve_assigner_name, + cve_date_published, + cve_date_updated, + } + } + + pub fn new_boxed( + id: Option, + vendor: Option, + product: Option, + product_version: Option, + product_type: Option, + cve_id: Option, + cve_state: Option, + cve_description: Option, + cve_assigner_id: Option, + cve_assigner_name: Option, + cve_date_published: Option, + cve_date_updated: Option, + ) -> Box { + Box::new(CreateBreachCommand::new( + id, + vendor, + product, + product_version, + product_type, + cve_id, + cve_state, + cve_description, + cve_assigner_id, + cve_assigner_name, + cve_date_published, + cve_date_updated, + )) + } +} + +impl Command for CreateBreachCommand { + fn command_type(&self) -> String { + CreateBreachCommand::COMMAND_TYPE.to_string() + } + + fn as_any(&self) -> &dyn std::any::Any { + self + } +} diff --git a/libs/cti/src/breaches/application/create_one/mod.rs b/libs/cti/src/breaches/application/create_one/mod.rs index e69de29..78661cb 100644 --- a/libs/cti/src/breaches/application/create_one/mod.rs +++ b/libs/cti/src/breaches/application/create_one/mod.rs @@ -0,0 +1 @@ +pub mod create_breach_command; \ No newline at end of file