1use crate::models;
12use serde::{Deserialize, Serialize};
13
14#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
16pub struct GlobalAdvisory {
17 #[serde(rename = "ghsa_id")]
19 pub ghsa_id: String,
20 #[serde(rename = "cve_id", deserialize_with = "Option::deserialize")]
22 pub cve_id: Option<String>,
23 #[serde(rename = "url")]
25 pub url: String,
26 #[serde(rename = "html_url")]
28 pub html_url: String,
29 #[serde(rename = "repository_advisory_url", deserialize_with = "Option::deserialize")]
31 pub repository_advisory_url: Option<String>,
32 #[serde(rename = "summary")]
34 pub summary: String,
35 #[serde(rename = "description", deserialize_with = "Option::deserialize")]
37 pub description: Option<String>,
38 #[serde(rename = "type")]
40 pub r#type: Type,
41 #[serde(rename = "severity")]
43 pub severity: Severity,
44 #[serde(rename = "source_code_location", deserialize_with = "Option::deserialize")]
46 pub source_code_location: Option<String>,
47 #[serde(rename = "identifiers", deserialize_with = "Option::deserialize")]
48 pub identifiers: Option<Vec<models::GlobalAdvisoryIdentifiersInner>>,
49 #[serde(rename = "references", deserialize_with = "Option::deserialize")]
50 pub references: Option<Vec<String>>,
51 #[serde(rename = "published_at")]
53 pub published_at: String,
54 #[serde(rename = "updated_at")]
56 pub updated_at: String,
57 #[serde(rename = "github_reviewed_at", deserialize_with = "Option::deserialize")]
59 pub github_reviewed_at: Option<String>,
60 #[serde(rename = "nvd_published_at", deserialize_with = "Option::deserialize")]
62 pub nvd_published_at: Option<String>,
63 #[serde(rename = "withdrawn_at", deserialize_with = "Option::deserialize")]
65 pub withdrawn_at: Option<String>,
66 #[serde(rename = "vulnerabilities", deserialize_with = "Option::deserialize")]
68 pub vulnerabilities: Option<Vec<models::Vulnerability>>,
69 #[serde(rename = "cvss", deserialize_with = "Option::deserialize")]
70 pub cvss: Option<Box<models::GlobalAdvisoryCvss>>,
71 #[serde(rename = "cwes", deserialize_with = "Option::deserialize")]
72 pub cwes: Option<Vec<models::GlobalAdvisoryCwesInner>>,
73 #[serde(rename = "credits", deserialize_with = "Option::deserialize")]
75 pub credits: Option<Vec<models::GlobalAdvisoryCreditsInner>>,
76}
77
78impl GlobalAdvisory {
79 pub fn new(ghsa_id: String, cve_id: Option<String>, url: String, html_url: String, repository_advisory_url: Option<String>, summary: String, description: Option<String>, r#type: Type, severity: Severity, source_code_location: Option<String>, identifiers: Option<Vec<models::GlobalAdvisoryIdentifiersInner>>, references: Option<Vec<String>>, published_at: String, updated_at: String, github_reviewed_at: Option<String>, nvd_published_at: Option<String>, withdrawn_at: Option<String>, vulnerabilities: Option<Vec<models::Vulnerability>>, cvss: Option<models::GlobalAdvisoryCvss>, cwes: Option<Vec<models::GlobalAdvisoryCwesInner>>, credits: Option<Vec<models::GlobalAdvisoryCreditsInner>>) -> GlobalAdvisory {
81 GlobalAdvisory {
82 ghsa_id,
83 cve_id,
84 url,
85 html_url,
86 repository_advisory_url,
87 summary,
88 description,
89 r#type,
90 severity,
91 source_code_location,
92 identifiers,
93 references,
94 published_at,
95 updated_at,
96 github_reviewed_at,
97 nvd_published_at,
98 withdrawn_at,
99 vulnerabilities,
100 cvss: cvss.map(Box::new),
101 cwes,
102 credits,
103 }
104 }
105}
106#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
108pub enum Type {
109 #[serde(rename = "reviewed")]
110 Reviewed,
111 #[serde(rename = "unreviewed")]
112 Unreviewed,
113 #[serde(rename = "malware")]
114 Malware,
115}
116
117impl Default for Type {
118 fn default() -> Type {
119 Self::Reviewed
120 }
121}
122#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
124pub enum Severity {
125 #[serde(rename = "critical")]
126 Critical,
127 #[serde(rename = "high")]
128 High,
129 #[serde(rename = "medium")]
130 Medium,
131 #[serde(rename = "low")]
132 Low,
133 #[serde(rename = "unknown")]
134 Unknown,
135}
136
137impl Default for Severity {
138 fn default() -> Severity {
139 Self::Critical
140 }
141}
142