Skip to content

Commit

Permalink
make cve id printable
Browse files Browse the repository at this point in the history
  • Loading branch information
n1nj4t4nuk1 committed Dec 3, 2024
1 parent 684cda0 commit 72ff068
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
6 changes: 3 additions & 3 deletions libs/cti/src/cves/application/create_one/cve_creator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@ impl<R: CveRepository, E: EventBus> CveCreator<R, E> {
date_published: CvePublicationDate,
description: CveDescription,
) -> Result<(), DomainError> {
debug!("Starting CVE creation");
debug!("Starting CVE creation for {}.", id);
let key = Cve::new(&id, &state, &date_published, &description);
let res = self.repository.create_one(&key).await;
if res.is_err() {
debug!("Error creating CVE with id: {}", id.value());
debug!("Error creating CVE with id: {}.", id);
return Err(res.err().unwrap());
}
let created_event = CveCreatedEvent::new_shared(&id, &state, &date_published, &description);
self.event_bus.publish(created_event).await;
debug!("CVE with id: {} created", id.value());
debug!("CVE with id: {} created.", id);
Ok(())
}
}
10 changes: 8 additions & 2 deletions libs/cti/src/cves/domain/entities/cve_id.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::shared::domain::errors::DomainError;
use std::hash::{Hash, Hasher};
use std::{hash::{Hash, Hasher}, path::Display};

#[derive(Debug)]
pub struct CveId {
Expand All @@ -26,7 +26,7 @@ impl CveId {
self.value.clone()
}

pub fn ref_value(&self) -> &String {
pub fn rvalue(&self) -> &String {
&self.value
}
}
Expand All @@ -50,3 +50,9 @@ impl Hash for CveId {
self.value.hash(state);
}
}

impl std::fmt::Display for CveId {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.value)
}
}

0 comments on commit 72ff068

Please sign in to comment.