-
Notifications
You must be signed in to change notification settings - Fork 9
/
ComponentReportVulnerability.java
261 lines (220 loc) · 6 KB
/
ComponentReportVulnerability.java
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
/*
* Copyright (c) 2018-present Sonatype, Inc. All rights reserved.
*
* This program is licensed to you under the Apache License Version 2.0,
* and you may not use this file except in compliance with the Apache License Version 2.0.
* You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the Apache License Version 2.0 is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
*/
package org.sonatype.ossindex.service.api.componentreport;
import java.io.Serializable;
import java.net.URI;
import java.util.List;
import java.util.Objects;
import javax.annotation.Nullable;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.base.MoreObjects;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
* {@link ComponentReport} vulnerability details.
*
* @since 1.0.0
*/
@ApiModel(description = "Component vulnerability")
@XmlAccessorType(XmlAccessType.FIELD)
public class ComponentReportVulnerability
implements Serializable
{
private static final long serialVersionUID = 3L;
@ApiModelProperty("Public identifier")
@JsonProperty
@XmlElement
private String id;
/**
* @since 1.5.0
*/
@ApiModelProperty("Display name")
@JsonProperty
@XmlElement
private String displayName;
@ApiModelProperty("Vulnerability title")
@JsonProperty
@XmlElement
private String title;
@ApiModelProperty("Vulnerability description")
@JsonProperty
@XmlElement
private String description;
@ApiModelProperty("CVSS score")
@JsonProperty
@XmlElement
private Float cvssScore;
@ApiModelProperty("CVSS vector")
@JsonProperty
@XmlElement
private String cvssVector;
@ApiModelProperty("CWE")
@JsonProperty
@XmlElement
private String cwe;
/**
* @since 1.0.3
*/
@ApiModelProperty("CVE")
@JsonProperty
@XmlElement
private String cve;
@ApiModelProperty("Vulnerability details reference")
@JsonProperty
@XmlElement
private URI reference;
/**
* Range of versions which affects the component containing the vulnerability.
*
* This is only applicable when using version-less requests.
*
* @since 1.1.0
*/
@ApiModelProperty("Affected version ranges")
@JsonProperty
@XmlElement
@Nullable
private List<String> versionRanges;
/**
* List of external references that provide additional information about the vulnerability
*
* @since 1.8.0
*/
@ApiModelProperty("External references related to the vulnerability")
@JsonProperty
@XmlElement
private List<URI> externalReferences;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getDisplayName() {
return displayName;
}
public void setDisplayName(final String displayName) {
this.displayName = displayName;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
// FIXME: check the actual nullability of this; maybe left over from history and could be simplified to non-nullable
public Float getCvssScore() {
return cvssScore;
}
public void setCvssScore(Float cvssScore) {
this.cvssScore = cvssScore;
}
public String getCvssVector() {
return cvssVector;
}
public void setCvssVector(String cvssVector) {
this.cvssVector = cvssVector;
}
public String getCwe() {
return cwe;
}
public void setCwe(String cwe) {
this.cwe = cwe;
}
/**
* @since 1.0.3
*/
public String getCve() {
return cve;
}
/**
* @since 1.0.3
*/
public void setCve(String cve) {
this.cve = cve;
}
public URI getReference() {
return reference;
}
public void setReference(URI reference) {
this.reference = reference;
}
/**
* @since 1.1.0
*/
@Nullable
public List<String> getVersionRanges() {
return versionRanges;
}
/**
* @since 1.1.0
*/
public void setVersionRanges(@Nullable final List<String> versionRanges) {
this.versionRanges = versionRanges;
}
/**
* @since 1.8.0
*/
public List<URI> getExternalReferences() {
return externalReferences;
}
/**
* @since 1.8.0
*/
public void setExternalReferences(final List<URI> externalReferences) {
this.externalReferences = externalReferences;
}
@Override
public boolean equals(final Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
ComponentReportVulnerability that = (ComponentReportVulnerability) o;
return Objects.equals(id, that.id) &&
Objects.equals(displayName, that.displayName) &&
Objects.equals(title, that.title) &&
Objects.equals(description, that.description) &&
Objects.equals(cvssScore, that.cvssScore) &&
Objects.equals(cvssVector, that.cvssVector) &&
Objects.equals(cwe, that.cwe) &&
Objects.equals(cve, that.cve) &&
Objects.equals(reference, that.reference) &&
Objects.equals(versionRanges, that.versionRanges) &&
Objects.equals(externalReferences, that.externalReferences);
}
@Override
public int hashCode() {
return Objects.hash(id, displayName, title, description, cvssScore, cvssVector, cwe, cve, reference, versionRanges,
externalReferences);
}
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
.add("id", id)
.add("title", title)
.add("description", description)
.toString();
}
}