1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.owasp.dependencycheck.xml.pom;
19
20 import java.io.Serializable;
21 import java.util.ArrayList;
22 import java.util.List;
23 import java.util.Properties;
24 import javax.annotation.concurrent.ThreadSafe;
25
26 import org.owasp.dependencycheck.utils.InterpolationUtil;
27
28
29
30
31
32
33 @ThreadSafe
34 public class Model implements Serializable {
35
36
37
38
39 private static final long serialVersionUID = -7648711671774349441L;
40
41
42
43
44 private String name;
45
46
47
48 private String organization;
49
50
51
52 private String organizationUrl;
53
54
55
56 private String description;
57
58
59
60 private String groupId;
61
62
63
64 private String artifactId;
65
66
67
68 private String version;
69
70
71
72 private String parentGroupId;
73
74
75
76 private String parentArtifactId;
77
78
79
80 private String parentVersion;
81
82
83
84 private final List<License> licenses = new ArrayList<>();
85
86
87
88 private final List<Developer> developers = new ArrayList<>();
89
90
91
92 private String projectURL;
93
94
95
96
97
98
99 public String getName() {
100 return name;
101 }
102
103
104
105
106
107
108 public void setName(String name) {
109 this.name = name;
110 }
111
112
113
114
115
116
117 public String getOrganization() {
118 return organization;
119 }
120
121
122
123
124
125
126 public void setOrganization(String organization) {
127 this.organization = organization;
128 }
129
130
131
132
133
134
135 public String getOrganizationUrl() {
136 return organizationUrl;
137 }
138
139
140
141
142
143
144 public void setOrganizationUrl(String organizationUrl) {
145 this.organizationUrl = organizationUrl;
146 }
147
148
149
150
151
152
153 public String getDescription() {
154 return description;
155 }
156
157
158
159
160
161
162 public void setDescription(String description) {
163 this.description = description;
164 }
165
166
167
168
169
170
171 public String getGroupId() {
172 return groupId;
173 }
174
175
176
177
178
179
180 public void setGroupId(String groupId) {
181 this.groupId = groupId;
182 }
183
184
185
186
187
188
189 public String getArtifactId() {
190 return artifactId;
191 }
192
193
194
195
196
197
198 public void setArtifactId(String artifactId) {
199 this.artifactId = artifactId;
200 }
201
202
203
204
205
206
207 public String getVersion() {
208 return version;
209 }
210
211
212
213
214
215
216 public void setVersion(String version) {
217 this.version = version;
218 }
219
220
221
222
223
224
225 public String getParentGroupId() {
226 return parentGroupId;
227 }
228
229
230
231
232
233
234 public void setParentGroupId(String parentGroupId) {
235 this.parentGroupId = parentGroupId;
236 }
237
238
239
240
241
242
243 public String getParentArtifactId() {
244 return parentArtifactId;
245 }
246
247
248
249
250
251
252 public void setParentArtifactId(String parentArtifactId) {
253 this.parentArtifactId = parentArtifactId;
254 }
255
256
257
258
259
260
261 public String getParentVersion() {
262 return parentVersion;
263 }
264
265
266
267
268
269
270 public void setParentVersion(String parentVersion) {
271 this.parentVersion = parentVersion;
272 }
273
274
275
276
277
278
279 public List<License> getLicenses() {
280 return licenses;
281 }
282
283
284
285
286
287
288 public void addLicense(License license) {
289 licenses.add(license);
290 }
291
292
293
294
295
296
297 public List<Developer> getDevelopers() {
298 return developers;
299 }
300
301
302
303
304
305
306 public void addDeveloper(Developer developer) {
307 developers.add(developer);
308 }
309
310
311
312
313
314
315 public String getProjectURL() {
316 return projectURL;
317 }
318
319
320
321
322
323
324 public void setProjectURL(String projectURL) {
325 this.projectURL = projectURL;
326 }
327
328
329
330
331
332
333 public void processProperties(Properties properties) {
334 if (properties == null) {
335 return;
336 }
337 this.description = InterpolationUtil.interpolate(this.description, properties);
338 for (License l : this.getLicenses()) {
339 l.setName(InterpolationUtil.interpolate(l.getName(), properties));
340 l.setUrl(InterpolationUtil.interpolate(l.getUrl(), properties));
341 }
342 this.name = InterpolationUtil.interpolate(this.name, properties);
343 this.projectURL = InterpolationUtil.interpolate(this.projectURL, properties);
344 this.organization = InterpolationUtil.interpolate(this.organization, properties);
345 this.parentGroupId = InterpolationUtil.interpolate(this.parentGroupId, properties);
346 this.parentArtifactId = InterpolationUtil.interpolate(this.parentArtifactId, properties);
347 this.parentVersion = InterpolationUtil.interpolate(this.parentVersion, properties);
348 }
349
350
351
352
353
354
355
356
357
358
359
360
361
362 public void setGAVFromPomDotProperties(Properties pomProperties) {
363 if (!pomProperties.containsKey("groupId") || !pomProperties.containsKey("artifactId") || !pomProperties.containsKey("version")) {
364 return;
365 }
366 this.groupId = pomProperties.getProperty("groupId");
367 this.artifactId = pomProperties.getProperty("artifactId");
368 this.version = pomProperties.getProperty("version");
369 }
370 }