Skip to main content

knowdit_kg_model/db/
audit_finding.rs

1use sea_orm::entity::prelude::*;
2use serde::{Deserialize, Serialize};
3
4pub use crate::audit_finding::FindingSeverity;
5
6/// One audit-finding node.
7///
8/// A row here is one of:
9/// - **Canonical**: no outgoing `finding_merge` edge points away from
10///   `self.id`. Canonical findings are the targets the global-link path
11///   writes against and the rows the mapper returns.
12/// - **Raw / merged-away**: a row in `finding_merge` has
13///   `from_finding_id = self.id`. The finding has been folded into another
14///   canonical finding and is kept as historical provenance. Raw findings
15///   may still carry `semantic_finding_link` rows from the in-project
16///   linking step (run before merge collapses anything).
17///
18/// Project provenance is recorded in the `project_finding` join table —
19/// a canonical merged finding may receive contributions from many
20/// historical projects. There is intentionally no scalar `project_id`
21/// column here.
22#[sea_orm::model]
23#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, DeriveEntityModel)]
24#[sea_orm(table_name = "audit_finding")]
25pub struct Model {
26    #[sea_orm(primary_key)]
27    pub id: i32,
28    #[sea_orm(column_type = "Text")]
29    pub title: String,
30    pub severity: FindingSeverity,
31    #[sea_orm(column_type = "Text")]
32    pub root_cause: String,
33    #[sea_orm(column_type = "Text")]
34    pub description: String,
35    #[sea_orm(column_type = "Text")]
36    pub patterns: String,
37    #[sea_orm(column_type = "Text")]
38    pub exploits: String,
39
40    #[sea_orm(has_many, via = "audit_finding_category")]
41    pub finding_categories: HasMany<super::finding_category::Entity>,
42    #[sea_orm(has_many, via = "semantic_finding_link")]
43    pub semantic_nodes: HasMany<super::semantic_node::Entity>,
44    #[sea_orm(has_many, via = "project_finding")]
45    pub projects: HasMany<super::project::Entity>,
46}
47
48impl ActiveModelBehavior for ActiveModel {}