-
Notifications
You must be signed in to change notification settings - Fork 775
Expand file tree
/
Copy pathGHCodeScanningAlert.java
More file actions
287 lines (255 loc) · 6.54 KB
/
GHCodeScanningAlert.java
File metadata and controls
287 lines (255 loc) · 6.54 KB
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
package org.kohsuke.github;
import com.fasterxml.jackson.annotation.JsonIgnore;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.io.IOException;
import java.net.URL;
import java.util.Date;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
/**
* Code scanning alert for a repository
*
* <a href="https://docs.github.com/en/rest/reference/code-scanning"></a>
*/
@SuppressFBWarnings(value = { "UUF_UNUSED_FIELD" }, justification = "JSON API")
public class GHCodeScanningAlert extends GHObject {
@JsonIgnore
private GHRepository owner;
private long number;
private String html_url;
private GHCodeScanningAlertState state;
private GHUser dismissed_by;
private String dismissed_at;
private String dismissed_reason;
private Tool tool;
private Rule rule;
private GHCodeScanningAlertInstance most_recent_instance;
private String instances_url;
GHCodeScanningAlert wrap(GHRepository owner) {
this.owner = owner;
return this;
}
/**
* Id/number of the alert.
*
* @return the id/number
* @see #getId()
*/
public long getNumber() {
return number;
}
/**
* Id/number of the alert.
*
* @return the id/number
* @see #getNumber()
*/
@Override
public long getId() {
return getNumber();
}
/**
* State of alert
*
* @return the state
*/
public GHCodeScanningAlertState getState() {
return state;
}
/**
* User that has dismissed the alert. Non-null when {@link #getState()} is <i>Dismissed</i>
*
* <p>
* Note: User object returned by code scanning GitHub API does not contain all fields. Use with caution
* </p>
*
* @return the user
*/
@SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected behavior")
public GHUser getDismissedBy() {
return dismissed_by;
}
/**
* Time when alert was dismissed. Non-null when {@link #getState()} is <i>Dismissed</i>
*
* @return the time
*/
public Date getDismissedAt() {
return GitHubClient.parseDate(dismissed_at);
}
/**
* Reason provided for dismissing the alert.
*
* @return the reason
*/
public String getDismissedReason() {
return dismissed_reason;
}
/**
* Code scanning tool that created this alert
*
* @return the tool
*/
public Tool getTool() {
return tool;
}
/**
* Code scanning rule that was violated, causing the alert
*
* @return the rule
*/
public Rule getRule() {
return rule;
}
/**
* Most recent instance of the alert
*
* @return most recent instance
*/
public GHCodeScanningAlertInstance getMostRecentInstance() {
return most_recent_instance;
}
/**
* List all instances of the alert
*
* @return the paged iterable
*/
public PagedIterable<GHCodeScanningAlertInstance> listAlertInstances() {
return new GHCodeScanningAlertInstancesIterable(this,
root().createRequest().withUrlPath(instances_url).build());
}
@Override
public URL getHtmlUrl() throws IOException {
return GitHubClient.parseURL(html_url);
}
/**
* Code scanning rule
*/
@SuppressFBWarnings(value = { "UWF_UNWRITTEN_FIELD" }, justification = "JSON API")
static class Rule {
private String id;
private String name;
private String description;
private String severity;
private String security_severity_level;
private String[] tags;
private String full_description;
private String help;
private String help_uri;
/**
* A unique identifier for the rule used to detect the alert.
*
* @return the id
*/
@Nullable
public String getId() {
return id;
}
/**
* The name of the rule used to detect the alert.
*
* @return the name
*/
public String getName() {
return name;
}
/**
* The severity of the alert.
*
* @return the severity
*/
@Nullable
public String getSeverity() {
return severity;
}
/**
* The security severity of the alert.
*
* @return the security severity
*/
@Nullable
public String getSecuritySeverityLevel() {
return security_severity_level;
}
/**
* A short description of the rule used to detect the alert.
*
* @return the description
*/
@Nonnull
public String getDescription() {
return description;
}
/**
* A set of tags applicable for the rule.
*
* @return the tags
*/
@Nullable
public String[] getTags() {
return tags;
}
// The following fields only appear on some endpoints.
// These might be empty on endpoints like listSecurityAlerts
/**
* Full description of rule
*
* @return the full description
*/
@Nonnull
public String getFullDescription() {
return full_description;
}
/**
* Help text for the rule
*
* @return the help text
*/
@Nullable
public String getHelp() {
return help;
}
/**
* A link to documentation for the rule used to detect the alert. Can be null.
*
* @return alert documentation url
*/
@Nullable
public String getHelpUri() {
return help_uri;
}
}
/**
* Code scanning tool
*/
@SuppressFBWarnings(value = { "UWF_UNWRITTEN_FIELD" }, justification = "JSON API")
static class Tool {
private String name;
private String guid;
private String version;
/**
* Name of code scanning tool
*
* @return the name
*/
public String getName() {
return name;
}
/**
* GUID of code scanning tool
*
* @return the GUID
*/
public String getGuid() {
return guid;
}
/**
* Version of code scanning tool
*
* @return the version
*/
public String getVersion() {
return version;
}
}
}