openapi_github/models/
global_advisory.rs

1/*
2 * GitHub's official OpenAPI spec + Octokit extension
3 *
4 * OpenAPI specs from https://github.com/github/rest-api-description with the 'x-octokit' extension required by the Octokit SDKs
5 *
6 * The version of the OpenAPI document: 16.6.0
7 * 
8 * Generated by: https://openapi-generator.tech
9 */
10
11use crate::models;
12use serde::{Deserialize, Serialize};
13
14/// GlobalAdvisory : A GitHub Security Advisory.
15#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
16pub struct GlobalAdvisory {
17    /// The GitHub Security Advisory ID.
18    #[serde(rename = "ghsa_id")]
19    pub ghsa_id: String,
20    /// The Common Vulnerabilities and Exposures (CVE) ID.
21    #[serde(rename = "cve_id", deserialize_with = "Option::deserialize")]
22    pub cve_id: Option<String>,
23    /// The API URL for the advisory.
24    #[serde(rename = "url")]
25    pub url: String,
26    /// The URL for the advisory.
27    #[serde(rename = "html_url")]
28    pub html_url: String,
29    /// The API URL for the repository advisory.
30    #[serde(rename = "repository_advisory_url", deserialize_with = "Option::deserialize")]
31    pub repository_advisory_url: Option<String>,
32    /// A short summary of the advisory.
33    #[serde(rename = "summary")]
34    pub summary: String,
35    /// A detailed description of what the advisory entails.
36    #[serde(rename = "description", deserialize_with = "Option::deserialize")]
37    pub description: Option<String>,
38    /// The type of advisory.
39    #[serde(rename = "type")]
40    pub r#type: Type,
41    /// The severity of the advisory.
42    #[serde(rename = "severity")]
43    pub severity: Severity,
44    /// The URL of the advisory's source code.
45    #[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    /// The date and time of when the advisory was published, in ISO 8601 format.
52    #[serde(rename = "published_at")]
53    pub published_at: String,
54    /// The date and time of when the advisory was last updated, in ISO 8601 format.
55    #[serde(rename = "updated_at")]
56    pub updated_at: String,
57    /// The date and time of when the advisory was reviewed by GitHub, in ISO 8601 format.
58    #[serde(rename = "github_reviewed_at", deserialize_with = "Option::deserialize")]
59    pub github_reviewed_at: Option<String>,
60    /// The date and time when the advisory was published in the National Vulnerability Database, in ISO 8601 format. This field is only populated when the advisory is imported from the National Vulnerability Database.
61    #[serde(rename = "nvd_published_at", deserialize_with = "Option::deserialize")]
62    pub nvd_published_at: Option<String>,
63    /// The date and time of when the advisory was withdrawn, in ISO 8601 format.
64    #[serde(rename = "withdrawn_at", deserialize_with = "Option::deserialize")]
65    pub withdrawn_at: Option<String>,
66    /// The products and respective version ranges affected by the advisory.
67    #[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    /// The users who contributed to the advisory.
74    #[serde(rename = "credits", deserialize_with = "Option::deserialize")]
75    pub credits: Option<Vec<models::GlobalAdvisoryCreditsInner>>,
76}
77
78impl GlobalAdvisory {
79    /// A GitHub Security Advisory.
80    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/// The type of advisory.
107#[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/// The severity of the advisory.
123#[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