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