openapi_github/models/
repository_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/// RepositoryAdvisory : A repository security advisory.
15#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
16pub struct RepositoryAdvisory {
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    /// A short summary of the advisory.
30    #[serde(rename = "summary")]
31    pub summary: String,
32    /// A detailed description of what the advisory entails.
33    #[serde(rename = "description", deserialize_with = "Option::deserialize")]
34    pub description: Option<String>,
35    /// The severity of the advisory.
36    #[serde(rename = "severity", deserialize_with = "Option::deserialize")]
37    pub severity: Option<Severity>,
38    /// The author of the advisory.
39    #[serde(rename = "author", deserialize_with = "Option::deserialize")]
40    pub author: Option<Box<models::SimpleUser>>,
41    /// The publisher of the advisory.
42    #[serde(rename = "publisher", deserialize_with = "Option::deserialize")]
43    pub publisher: Option<Box<models::SimpleUser>>,
44    #[serde(rename = "identifiers")]
45    pub identifiers: Vec<models::GlobalAdvisoryIdentifiersInner>,
46    /// The state of the advisory.
47    #[serde(rename = "state")]
48    pub state: State,
49    /// The date and time of when the advisory was created, in ISO 8601 format.
50    #[serde(rename = "created_at", deserialize_with = "Option::deserialize")]
51    pub created_at: Option<String>,
52    /// The date and time of when the advisory was last updated, in ISO 8601 format.
53    #[serde(rename = "updated_at", deserialize_with = "Option::deserialize")]
54    pub updated_at: Option<String>,
55    /// The date and time of when the advisory was published, in ISO 8601 format.
56    #[serde(rename = "published_at", deserialize_with = "Option::deserialize")]
57    pub published_at: Option<String>,
58    /// The date and time of when the advisory was closed, in ISO 8601 format.
59    #[serde(rename = "closed_at", deserialize_with = "Option::deserialize")]
60    pub closed_at: Option<String>,
61    /// The date and time of when the advisory was withdrawn, in ISO 8601 format.
62    #[serde(rename = "withdrawn_at", deserialize_with = "Option::deserialize")]
63    pub withdrawn_at: Option<String>,
64    #[serde(rename = "submission", deserialize_with = "Option::deserialize")]
65    pub submission: Option<Box<models::RepositoryAdvisorySubmission>>,
66    #[serde(rename = "vulnerabilities", deserialize_with = "Option::deserialize")]
67    pub vulnerabilities: Option<Vec<models::RepositoryAdvisoryVulnerability>>,
68    #[serde(rename = "cvss", deserialize_with = "Option::deserialize")]
69    pub cvss: Option<Box<models::GlobalAdvisoryCvss>>,
70    #[serde(rename = "cwes", deserialize_with = "Option::deserialize")]
71    pub cwes: Option<Vec<models::GlobalAdvisoryCwesInner>>,
72    /// A list of only the CWE IDs.
73    #[serde(rename = "cwe_ids", deserialize_with = "Option::deserialize")]
74    pub cwe_ids: Option<Vec<String>>,
75    #[serde(rename = "credits", deserialize_with = "Option::deserialize")]
76    pub credits: Option<Vec<models::RepositoryAdvisoryCreditsInner>>,
77    #[serde(rename = "credits_detailed", deserialize_with = "Option::deserialize")]
78    pub credits_detailed: Option<Vec<models::RepositoryAdvisoryCredit>>,
79    /// A list of users that collaborate on the advisory.
80    #[serde(rename = "collaborating_users", deserialize_with = "Option::deserialize")]
81    pub collaborating_users: Option<Vec<models::SimpleUser>>,
82    /// A list of teams that collaborate on the advisory.
83    #[serde(rename = "collaborating_teams", deserialize_with = "Option::deserialize")]
84    pub collaborating_teams: Option<Vec<models::Team>>,
85    /// A temporary private fork of the advisory's repository for collaborating on a fix.
86    #[serde(rename = "private_fork", deserialize_with = "Option::deserialize")]
87    pub private_fork: Option<Box<models::SimpleRepository>>,
88}
89
90impl RepositoryAdvisory {
91    /// A repository security advisory.
92    pub fn new(ghsa_id: String, cve_id: Option<String>, url: String, html_url: String, summary: String, description: Option<String>, severity: Option<Severity>, author: Option<models::SimpleUser>, publisher: Option<models::SimpleUser>, identifiers: Vec<models::GlobalAdvisoryIdentifiersInner>, state: State, created_at: Option<String>, updated_at: Option<String>, published_at: Option<String>, closed_at: Option<String>, withdrawn_at: Option<String>, submission: Option<models::RepositoryAdvisorySubmission>, vulnerabilities: Option<Vec<models::RepositoryAdvisoryVulnerability>>, cvss: Option<models::GlobalAdvisoryCvss>, cwes: Option<Vec<models::GlobalAdvisoryCwesInner>>, cwe_ids: Option<Vec<String>>, credits: Option<Vec<models::RepositoryAdvisoryCreditsInner>>, credits_detailed: Option<Vec<models::RepositoryAdvisoryCredit>>, collaborating_users: Option<Vec<models::SimpleUser>>, collaborating_teams: Option<Vec<models::Team>>, private_fork: Option<models::SimpleRepository>) -> RepositoryAdvisory {
93        RepositoryAdvisory {
94            ghsa_id,
95            cve_id,
96            url,
97            html_url,
98            summary,
99            description,
100            severity,
101            author: author.map(Box::new),
102            publisher: publisher.map(Box::new),
103            identifiers,
104            state,
105            created_at,
106            updated_at,
107            published_at,
108            closed_at,
109            withdrawn_at,
110            submission: submission.map(Box::new),
111            vulnerabilities,
112            cvss: cvss.map(Box::new),
113            cwes,
114            cwe_ids,
115            credits,
116            credits_detailed,
117            collaborating_users,
118            collaborating_teams,
119            private_fork: private_fork.map(Box::new),
120        }
121    }
122}
123/// The severity of the advisory.
124#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
125pub enum Severity {
126    #[serde(rename = "critical")]
127    Critical,
128    #[serde(rename = "high")]
129    High,
130    #[serde(rename = "medium")]
131    Medium,
132    #[serde(rename = "low")]
133    Low,
134}
135
136impl Default for Severity {
137    fn default() -> Severity {
138        Self::Critical
139    }
140}
141/// The state of the advisory.
142#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
143pub enum State {
144    #[serde(rename = "published")]
145    Published,
146    #[serde(rename = "closed")]
147    Closed,
148    #[serde(rename = "withdrawn")]
149    Withdrawn,
150    #[serde(rename = "draft")]
151    Draft,
152    #[serde(rename = "triage")]
153    Triage,
154}
155
156impl Default for State {
157    fn default() -> State {
158        Self::Published
159    }
160}
161