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 type SecretScanningAlertUpdateOptions struct {
68
69
70 State *string `url:"state,omitempty"`
71
72
73 SecretType *string `url:"secret_type,omitempty"`
74
75
76
77 Resolution *string `url:"resolution,omitempty"`
78 }
79
80
81
82
83
84
85
86 func (s *SecretScanningService) ListAlertsForEnterprise(ctx context.Context, enterprise string, opts *SecretScanningAlertListOptions) ([]*SecretScanningAlert, *Response, error) {
87 u := fmt.Sprintf("enterprises/%v/secret-scanning/alerts", enterprise)
88 u, err := addOptions(u, opts)
89 if err != nil {
90 return nil, nil, err
91 }
92
93 req, err := s.client.NewRequest("GET", u, nil)
94 if err != nil {
95 return nil, nil, err
96 }
97
98 var alerts []*SecretScanningAlert
99 resp, err := s.client.Do(ctx, req, &alerts)
100 if err != nil {
101 return nil, resp, err
102 }
103
104 return alerts, resp, nil
105 }
106
107
108
109
110
111
112
113 func (s *SecretScanningService) ListAlertsForOrg(ctx context.Context, org string, opts *SecretScanningAlertListOptions) ([]*SecretScanningAlert, *Response, error) {
114 u := fmt.Sprintf("orgs/%v/secret-scanning/alerts", org)
115 u, err := addOptions(u, opts)
116 if err != nil {
117 return nil, nil, err
118 }
119
120 req, err := s.client.NewRequest("GET", u, nil)
121 if err != nil {
122 return nil, nil, err
123 }
124
125 var alerts []*SecretScanningAlert
126 resp, err := s.client.Do(ctx, req, &alerts)
127 if err != nil {
128 return nil, resp, err
129 }
130
131 return alerts, resp, nil
132 }
133
134
135
136
137
138
139
140 func (s *SecretScanningService) ListAlertsForRepo(ctx context.Context, owner, repo string, opts *SecretScanningAlertListOptions) ([]*SecretScanningAlert, *Response, error) {
141 u := fmt.Sprintf("repos/%v/%v/secret-scanning/alerts", owner, repo)
142 u, err := addOptions(u, opts)
143 if err != nil {
144 return nil, nil, err
145 }
146
147 req, err := s.client.NewRequest("GET", u, nil)
148 if err != nil {
149 return nil, nil, err
150 }
151
152 var alerts []*SecretScanningAlert
153 resp, err := s.client.Do(ctx, req, &alerts)
154 if err != nil {
155 return nil, resp, err
156 }
157
158 return alerts, resp, nil
159 }
160
161
162
163
164
165
166
167 func (s *SecretScanningService) GetAlert(ctx context.Context, owner, repo string, number int64) (*SecretScanningAlert, *Response, error) {
168 u := fmt.Sprintf("repos/%v/%v/secret-scanning/alerts/%v", owner, repo, number)
169
170 req, err := s.client.NewRequest("GET", u, nil)
171 if err != nil {
172 return nil, nil, err
173 }
174
175 var alert *SecretScanningAlert
176 resp, err := s.client.Do(ctx, req, &alert)
177 if err != nil {
178 return nil, resp, err
179 }
180
181 return alert, resp, nil
182 }
183
184
185
186
187
188
189
190 func (s *SecretScanningService) UpdateAlert(ctx context.Context, owner, repo string, number int64, opts *SecretScanningAlertUpdateOptions) (*SecretScanningAlert, *Response, error) {
191 u := fmt.Sprintf("repos/%v/%v/secret-scanning/alerts/%v", owner, repo, number)
192
193 req, err := s.client.NewRequest("PATCH", u, opts)
194 if err != nil {
195 return nil, nil, err
196 }
197
198 var alert *SecretScanningAlert
199 resp, err := s.client.Do(ctx, req, &alert)
200 if err != nil {
201 return nil, resp, err
202 }
203
204 return alert, resp, nil
205 }
206
207
208
209
210
211
212
213 func (s *SecretScanningService) ListLocationsForAlert(ctx context.Context, owner, repo string, number int64, opts *ListOptions) ([]*SecretScanningAlertLocation, *Response, error) {
214 u := fmt.Sprintf("repos/%v/%v/secret-scanning/alerts/%v/locations", owner, repo, number)
215 u, err := addOptions(u, opts)
216 if err != nil {
217 return nil, nil, err
218 }
219
220 req, err := s.client.NewRequest("GET", u, nil)
221 if err != nil {
222 return nil, nil, err
223 }
224
225 var locations []*SecretScanningAlertLocation
226 resp, err := s.client.Do(ctx, req, &locations)
227 if err != nil {
228 return nil, resp, err
229 }
230
231 return locations, resp, nil
232 }
233
View as plain text