1
2
3
4
5
6 package github
7
8 import (
9 "context"
10 "fmt"
11 )
12
13
14
15 type SecretScanningService service
16
17
18 type SecretScanningAlert struct {
19 Number *int `json:"number,omitempty"`
20 CreatedAt *Timestamp `json:"created_at,omitempty"`
21 URL *string `json:"url,omitempty"`
22 HTMLURL *string `json:"html_url,omitempty"`
23 LocationsURL *string `json:"locations_url,omitempty"`
24 State *string `json:"state,omitempty"`
25 Resolution *string `json:"resolution,omitempty"`
26 ResolvedAt *Timestamp `json:"resolved_at,omitempty"`
27 ResolvedBy *User `json:"resolved_by,omitempty"`
28 SecretType *string `json:"secret_type,omitempty"`
29 SecretTypeDisplayName *string `json:"secret_type_display_name,omitempty"`
30 Secret *string `json:"secret,omitempty"`
31 Repository *Repository `json:"repository,omitempty"`
32 }
33
34
35 type SecretScanningAlertLocation struct {
36 Type *string `json:"type,omitempty"`
37 Details *SecretScanningAlertLocationDetails `json:"details,omitempty"`
38 }
39
40
41 type SecretScanningAlertLocationDetails struct {
42 Path *string `json:"path,omitempty"`
43 Startline *int `json:"start_line,omitempty"`
44 EndLine *int `json:"end_line,omitempty"`
45 StartColumn *int `json:"start_column,omitempty"`
46 EndColumn *int `json:"end_column,omitempty"`
47 BlobSHA *string `json:"blob_sha,omitempty"`
48 BlobURL *string `json:"blob_url,omitempty"`
49 CommitSHA *string `json:"commit_sha,omitempty"`
50 CommitURL *string `json:"commit_url,omitempty"`
51 }
52
53
54 type SecretScanningAlertListOptions struct {
55
56 State string `url:"state,omitempty"`
57
58
59 SecretType string `url:"secret_type,omitempty"`
60
61
62
63 Resolution string `url:"resolution,omitempty"`
64
65 ListCursorOptions
66
67
68
69
70
71
72
73 ListOptions
74 }
75
76
77 type SecretScanningAlertUpdateOptions struct {
78
79
80 State *string `url:"state,omitempty"`
81
82
83 SecretType *string `url:"secret_type,omitempty"`
84
85
86
87 Resolution *string `url:"resolution,omitempty"`
88 }
89
90
91
92
93
94
95
96 func (s *SecretScanningService) ListAlertsForEnterprise(ctx context.Context, enterprise string, opts *SecretScanningAlertListOptions) ([]*SecretScanningAlert, *Response, error) {
97 u := fmt.Sprintf("enterprises/%v/secret-scanning/alerts", enterprise)
98 u, err := addOptions(u, opts)
99 if err != nil {
100 return nil, nil, err
101 }
102
103 req, err := s.client.NewRequest("GET", u, nil)
104 if err != nil {
105 return nil, nil, err
106 }
107
108 var alerts []*SecretScanningAlert
109 resp, err := s.client.Do(ctx, req, &alerts)
110 if err != nil {
111 return nil, resp, err
112 }
113
114 return alerts, resp, nil
115 }
116
117
118
119
120
121
122
123 func (s *SecretScanningService) ListAlertsForOrg(ctx context.Context, org string, opts *SecretScanningAlertListOptions) ([]*SecretScanningAlert, *Response, error) {
124 u := fmt.Sprintf("orgs/%v/secret-scanning/alerts", org)
125 u, err := addOptions(u, opts)
126 if err != nil {
127 return nil, nil, err
128 }
129
130 req, err := s.client.NewRequest("GET", u, nil)
131 if err != nil {
132 return nil, nil, err
133 }
134
135 var alerts []*SecretScanningAlert
136 resp, err := s.client.Do(ctx, req, &alerts)
137 if err != nil {
138 return nil, resp, err
139 }
140
141 return alerts, resp, nil
142 }
143
144
145
146
147
148
149
150 func (s *SecretScanningService) ListAlertsForRepo(ctx context.Context, owner, repo string, opts *SecretScanningAlertListOptions) ([]*SecretScanningAlert, *Response, error) {
151 u := fmt.Sprintf("repos/%v/%v/secret-scanning/alerts", owner, repo)
152 u, err := addOptions(u, opts)
153 if err != nil {
154 return nil, nil, err
155 }
156
157 req, err := s.client.NewRequest("GET", u, nil)
158 if err != nil {
159 return nil, nil, err
160 }
161
162 var alerts []*SecretScanningAlert
163 resp, err := s.client.Do(ctx, req, &alerts)
164 if err != nil {
165 return nil, resp, err
166 }
167
168 return alerts, resp, nil
169 }
170
171
172
173
174
175
176
177 func (s *SecretScanningService) GetAlert(ctx context.Context, owner, repo string, number int64) (*SecretScanningAlert, *Response, error) {
178 u := fmt.Sprintf("repos/%v/%v/secret-scanning/alerts/%v", owner, repo, number)
179
180 req, err := s.client.NewRequest("GET", u, nil)
181 if err != nil {
182 return nil, nil, err
183 }
184
185 var alert *SecretScanningAlert
186 resp, err := s.client.Do(ctx, req, &alert)
187 if err != nil {
188 return nil, resp, err
189 }
190
191 return alert, resp, nil
192 }
193
194
195
196
197
198
199
200 func (s *SecretScanningService) UpdateAlert(ctx context.Context, owner, repo string, number int64, opts *SecretScanningAlertUpdateOptions) (*SecretScanningAlert, *Response, error) {
201 u := fmt.Sprintf("repos/%v/%v/secret-scanning/alerts/%v", owner, repo, number)
202
203 req, err := s.client.NewRequest("PATCH", u, opts)
204 if err != nil {
205 return nil, nil, err
206 }
207
208 var alert *SecretScanningAlert
209 resp, err := s.client.Do(ctx, req, &alert)
210 if err != nil {
211 return nil, resp, err
212 }
213
214 return alert, resp, nil
215 }
216
217
218
219
220
221
222
223 func (s *SecretScanningService) ListLocationsForAlert(ctx context.Context, owner, repo string, number int64, opts *ListOptions) ([]*SecretScanningAlertLocation, *Response, error) {
224 u := fmt.Sprintf("repos/%v/%v/secret-scanning/alerts/%v/locations", owner, repo, number)
225 u, err := addOptions(u, opts)
226 if err != nil {
227 return nil, nil, err
228 }
229
230 req, err := s.client.NewRequest("GET", u, nil)
231 if err != nil {
232 return nil, nil, err
233 }
234
235 var locations []*SecretScanningAlertLocation
236 resp, err := s.client.Do(ctx, req, &locations)
237 if err != nil {
238 return nil, resp, err
239 }
240
241 return locations, resp, nil
242 }
243
View as plain text