syncable_cli/analyzer/security/
core.rs1use std::collections::HashMap;
6use std::path::PathBuf;
7use serde::{Deserialize, Serialize};
8
9#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord, Hash)]
11pub enum SecuritySeverity {
12 Critical,
13 High,
14 Medium,
15 Low,
16 Info,
17}
18
19#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)]
21pub enum SecurityCategory {
22 SecretsExposure,
24 InsecureConfiguration,
26 CodeSecurityPattern,
28 InfrastructureSecurity,
30 AuthenticationSecurity,
32 DataProtection,
34 NetworkSecurity,
36 Compliance,
38}
39
40#[derive(Debug, Clone, Serialize, Deserialize)]
42pub struct SecurityFinding {
43 pub id: String,
44 pub title: String,
45 pub description: String,
46 pub severity: SecuritySeverity,
47 pub category: SecurityCategory,
48 pub file_path: Option<PathBuf>,
49 pub line_number: Option<usize>,
50 pub column_number: Option<usize>,
51 pub evidence: Option<String>,
52 pub remediation: Vec<String>,
53 pub references: Vec<String>,
54 pub cwe_id: Option<String>,
55 pub compliance_frameworks: Vec<String>,
56}
57
58#[derive(Debug, Serialize, Deserialize)]
60pub struct SecurityReport {
61 pub analyzed_at: chrono::DateTime<chrono::Utc>,
62 pub overall_score: f32, pub risk_level: SecuritySeverity,
64 pub total_findings: usize,
65 pub findings_by_severity: HashMap<SecuritySeverity, usize>,
66 pub findings_by_category: HashMap<SecurityCategory, usize>,
67 pub findings: Vec<SecurityFinding>,
68 pub recommendations: Vec<String>,
69 pub compliance_status: HashMap<String, ComplianceStatus>,
70}
71
72#[derive(Debug, Clone, Serialize, Deserialize)]
74pub struct ComplianceStatus {
75 pub framework: String,
76 pub coverage: f32, pub missing_controls: Vec<String>,
78 pub recommendations: Vec<String>,
79}
80
81pub trait SecurityAnalyzer {
83 type Config;
84 type Error: std::error::Error;
85
86 fn analyze_project(&self, project_root: &std::path::Path) -> Result<SecurityReport, Self::Error>;
88
89 fn config(&self) -> &Self::Config;
91
92 fn supported_extensions(&self) -> Vec<&'static str>;
94}