Skip to content

Commit

Permalink
Enums and remove of duplicated struct in Code Scannings
Browse files Browse the repository at this point in the history
  • Loading branch information
vlad1slav committed Nov 10, 2024
1 parent b70f438 commit 2d494de
Showing 1 changed file with 32 additions and 57 deletions.
89 changes: 32 additions & 57 deletions src/models/code_scannings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub struct CodeScanningAlert {
#[serde(skip_serializing_if = "Option::is_none")]
pub fixed_at: Option<chrono::DateTime<chrono::Utc>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub dismissed_by: Option<Dismisser>,
pub dismissed_by: Option<SimpleUser>,
#[serde(skip_serializing_if = "Option::is_none")]
pub dismissed_at: Option<chrono::DateTime<chrono::Utc>>,
#[serde(skip_serializing_if = "Option::is_none")]
Expand Down Expand Up @@ -48,31 +48,24 @@ pub enum DismissedReason {
UsedInTests,
}

#[derive(Debug, Clone, Hash, Eq, PartialEq, Serialize, Deserialize)]
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct Dismisser {
// isn't is the same as SimpleUser?
pub login: String,
pub id: UserId,
pub node_id: String,
pub avatar_url: Url,
pub gravatar_id: String,
pub url: Url,
pub html_url: Url,
pub followers_url: Url,
pub following_url: Url,
pub gists_url: Url,
pub starred_url: Url,
pub subscriptions_url: Url,
pub organizations_url: Url,
pub repos_url: Url,
pub events_url: Url,
pub received_events_url: Url,
pub r#type: String,
pub site_admin: bool,
pub patch_url: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub email: Option<String>,
#[serde(rename_all = "snake_case")]
pub enum Severity {
None,
Note,
Warning,
Error,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
#[serde(rename_all = "snake_case")]
pub enum SecuritySeverityLevel {
Low,
Medium,
High,
Critical,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
Expand All @@ -82,29 +75,14 @@ pub struct Rule {
pub id: Option<String>,
pub name: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub severity: Option<String>, /* per documentation is is an enum, should we change the type?:
"description": "The severity of the alert.",
"enum": [
"none",
"note",
"warning",
"error",
null
]*/
pub severity: Option<Severity>,
pub description: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub full_description: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub tags: Option<Vec<String>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub security_severity_level: Option<String>, /* per documentation it is enum, shoud we change it?:
"enum": [
"low",
"medium",
"high",
"critical",
null
] */
pub security_severity_level: Option<SecuritySeverityLevel>,
#[serde(skip_serializing_if = "Option::is_none")]
pub help: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
Expand All @@ -121,6 +99,16 @@ pub struct Tool {
pub version: Option<String>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
#[serde(rename_all = "snake_case")]
pub enum Classifications {
Source,
Generated,
Test,
Library,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct MostRecentInstance {
Expand All @@ -129,24 +117,11 @@ pub struct MostRecentInstance {
pub analysis_key: String,
pub environment: String,
pub category: String,
pub state: String, /* change to enum? doc:
"enum": [
"open",
"dismissed",
"fixed",
null
] */
pub state: Option<CodeScanningState>,
pub commit_sha: String,
pub message: Message,
pub location: Location,
pub classifications: Vec<String>, /* change to enum? doc:
"enum": [
"source",
"generated",
"test",
"library",
null
] */
pub classifications: Vec<Classifications>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
Expand Down

0 comments on commit 2d494de

Please sign in to comment.