summaryrefslogtreecommitdiff
path: root/octosentry/GitHubAPIModels.swift
blob: 2b95b708836fb3872d17379d6e7853cbbab433f6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
//
//  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
    }
}

nonisolated struct GitHubRepoDTO: Decodable {
    let fullName: String

    enum CodingKeys: String, CodingKey {
        case fullName = "full_name"
    }
}