summaryrefslogtreecommitdiff
path: root/octosentry/GitHubAPIModels.swift
diff options
context:
space:
mode:
Diffstat (limited to 'octosentry/GitHubAPIModels.swift')
-rw-r--r--octosentry/GitHubAPIModels.swift88
1 files changed, 88 insertions, 0 deletions
diff --git a/octosentry/GitHubAPIModels.swift b/octosentry/GitHubAPIModels.swift
new file mode 100644
index 0000000..3a84aa8
--- /dev/null
+++ b/octosentry/GitHubAPIModels.swift
@@ -0,0 +1,88 @@
+//
+// GitHubAPIModels.swift
+// octosentry
+//
+// Decodable wire types for the three GitHub REST alert endpoints. Kept
+// private to this file — GitHubSecurityAPIClient maps them into SecurityEvent.
+//
+
+import Foundation
+
+nonisolated struct DependabotAlertDTO: Decodable {
+ let number: Int
+ let htmlUrl: URL
+ let createdAt: Date
+ let updatedAt: Date
+ let securityAdvisory: SecurityAdvisory
+
+ struct SecurityAdvisory: Decodable {
+ let summary: String
+ let severity: String
+ }
+
+ enum CodingKeys: String, CodingKey {
+ case number
+ case htmlUrl = "html_url"
+ case createdAt = "created_at"
+ case updatedAt = "updated_at"
+ case securityAdvisory = "security_advisory"
+ }
+}
+
+nonisolated struct CodeScanningAlertDTO: Decodable {
+ let number: Int
+ let htmlUrl: URL
+ let createdAt: Date
+ let updatedAt: Date
+ let rule: Rule
+ let mostRecentInstance: MostRecentInstance?
+
+ struct Rule: Decodable {
+ let id: String?
+ let description: String?
+ let severity: String?
+ let securitySeverityLevel: String?
+
+ enum CodingKeys: String, CodingKey {
+ case id
+ case description
+ case severity
+ case securitySeverityLevel = "security_severity_level"
+ }
+ }
+
+ struct MostRecentInstance: Decodable {
+ let message: Message?
+
+ struct Message: Decodable {
+ let text: String?
+ }
+ }
+
+ enum CodingKeys: String, CodingKey {
+ case number
+ case htmlUrl = "html_url"
+ case createdAt = "created_at"
+ case updatedAt = "updated_at"
+ case rule
+ case mostRecentInstance = "most_recent_instance"
+ }
+}
+
+nonisolated struct SecretScanningAlertDTO: Decodable {
+ let number: Int
+ let htmlUrl: URL
+ let createdAt: Date
+ let updatedAt: Date
+ let secretTypeDisplayName: String
+ let validity: String?
+
+ enum CodingKeys: String, CodingKey {
+ case number
+ case htmlUrl = "html_url"
+ case createdAt = "created_at"
+ case updatedAt = "updated_at"
+ case secretTypeDisplayName = "secret_type_display_name"
+ case validity
+ }
+}