Skip to content

Commit

Permalink
add missing log.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
syncpark committed Dec 11, 2023
1 parent 8c7910c commit c0c2def
Showing 1 changed file with 65 additions and 0 deletions.
65 changes: 65 additions & 0 deletions src/graphql/event/log.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
use super::TriageScore;
use async_graphql::Object;
use chrono::{DateTime, Utc};
use review_database as database;

#[allow(clippy::module_name_repetitions)]
pub(super) struct LogThreat {
inner: database::LogThreat,
}

#[Object]
impl LogThreat {
async fn time(&self) -> DateTime<Utc> {
self.inner.time
}

async fn source(&self) -> &str {
&self.inner.source
}

async fn service(&self) -> &str {
&self.inner.service
}

async fn content(&self) -> &str {
&self.inner.content
}

async fn db_name(&self) -> &str {
&self.inner.db_name
}

async fn rule_id(&self) -> u32 {
self.inner.rule_id
}

async fn matched_to(&self) -> &str {
&self.inner.matched_to
}

async fn cluster_id(&self) -> usize {
self.inner.cluster_id
}

async fn attack_kind(&self) -> &str {
&self.inner.attack_kind
}

async fn confidence(&self) -> f32 {
self.inner.confidence
}

async fn triage_scores(&self) -> Option<Vec<TriageScore>> {
self.inner
.triage_scores
.as_ref()
.map(|scores| scores.iter().map(Into::into).collect::<Vec<TriageScore>>())
}
}

impl From<database::LogThreat> for LogThreat {
fn from(inner: database::LogThreat) -> Self {
Self { inner }
}
}

0 comments on commit c0c2def

Please sign in to comment.