Some checks failed
CI / Format (push) Successful in 3s
CI / Clippy (push) Successful in 4m3s
CI / Security Audit (push) Successful in 1m38s
CI / Tests (push) Successful in 4m44s
CI / Detect Changes (push) Successful in 2s
CI / Deploy Agent (push) Successful in 2s
CI / Deploy Dashboard (push) Successful in 2s
CI / Deploy Docs (push) Has been skipped
CI / Deploy MCP (push) Failing after 2s
80 lines
2.1 KiB
Rust
80 lines
2.1 KiB
Rust
use chrono::{DateTime, Utc};
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
|
|
#[serde(rename_all = "lowercase")]
|
|
pub enum TrackerType {
|
|
GitHub,
|
|
GitLab,
|
|
Jira,
|
|
}
|
|
|
|
impl std::fmt::Display for TrackerType {
|
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
match self {
|
|
Self::GitHub => write!(f, "github"),
|
|
Self::GitLab => write!(f, "gitlab"),
|
|
Self::Jira => write!(f, "jira"),
|
|
}
|
|
}
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
|
|
#[serde(rename_all = "snake_case")]
|
|
pub enum IssueStatus {
|
|
Open,
|
|
InProgress,
|
|
Closed,
|
|
Resolved,
|
|
}
|
|
|
|
impl std::fmt::Display for IssueStatus {
|
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
match self {
|
|
Self::Open => write!(f, "open"),
|
|
Self::InProgress => write!(f, "in_progress"),
|
|
Self::Closed => write!(f, "closed"),
|
|
Self::Resolved => write!(f, "resolved"),
|
|
}
|
|
}
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
pub struct TrackerIssue {
|
|
#[serde(rename = "_id", skip_serializing_if = "Option::is_none")]
|
|
pub id: Option<bson::oid::ObjectId>,
|
|
pub finding_id: String,
|
|
pub tracker_type: TrackerType,
|
|
pub external_id: String,
|
|
pub external_url: String,
|
|
pub title: String,
|
|
pub status: IssueStatus,
|
|
#[serde(with = "super::serde_helpers::bson_datetime")]
|
|
pub created_at: DateTime<Utc>,
|
|
#[serde(with = "super::serde_helpers::bson_datetime")]
|
|
pub updated_at: DateTime<Utc>,
|
|
}
|
|
|
|
impl TrackerIssue {
|
|
pub fn new(
|
|
finding_id: String,
|
|
tracker_type: TrackerType,
|
|
external_id: String,
|
|
external_url: String,
|
|
title: String,
|
|
) -> Self {
|
|
let now = Utc::now();
|
|
Self {
|
|
id: None,
|
|
finding_id,
|
|
tracker_type,
|
|
external_id,
|
|
external_url,
|
|
title,
|
|
status: IssueStatus::Open,
|
|
created_at: now,
|
|
updated_at: now,
|
|
}
|
|
}
|
|
}
|