Skip to main content

crawlkit_plugin_sdk/
finding.rs

1//! Finding types for plugins.
2
3use serde::{Deserialize, Serialize};
4
5/// Severity of a finding.
6#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
7pub enum Severity {
8    Critical,
9    Error,
10    Warning,
11    Info,
12}
13
14impl Severity {
15    /// Convert to string.
16    pub fn as_str(&self) -> &'static str {
17        match self {
18            Severity::Critical => "critical",
19            Severity::Error => "error",
20            Severity::Warning => "warning",
21            Severity::Info => "info",
22        }
23    }
24}
25
26/// A single finding from an analyzer.
27#[derive(Debug, Clone, Serialize, Deserialize)]
28pub struct Finding {
29    /// Issue severity.
30    pub severity: Severity,
31    /// Issue category.
32    pub category: String,
33    /// Machine-readable issue code.
34    pub code: String,
35    /// Short human-readable title.
36    pub title: String,
37    /// Detailed description.
38    pub description: String,
39    /// URL where the issue was found.
40    pub url: String,
41    /// Recommendation for fixing.
42    pub recommendation: String,
43}