Skip to content

Commit ef43dd1

Browse files
committed
Fix Issue
Signed-off-by: Alex Alzate <[email protected]>
1 parent 73cce4b commit ef43dd1

File tree

6 files changed

+32
-12
lines changed

6 files changed

+32
-12
lines changed

src/main/java/org/cyclonedx/model/Service.java

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
"endpoints",
5151
"authenticated",
5252
"xTrustBoundary",
53+
"trustZone",
5354
"data",
5455
"licenses",
5556
"externalReferences",
@@ -74,6 +75,8 @@ public class Service extends ExtensibleElement {
7475
@JacksonXmlProperty(localName = "x-trust-boundary")
7576
@JsonProperty("x-trust-boundary")
7677
private Boolean xTrustBoundary;
78+
@VersionFilter(Version.VERSION_15)
79+
private String trustZone;
7780
private List<ServiceData> data;
7881
private LicenseChoice licenses;
7982
private List<ExternalReference> externalReferences;
@@ -269,6 +272,14 @@ public void setTags(final Tags tags) {
269272
this.tags = tags;
270273
}
271274

275+
public String getTrustZone() {
276+
return trustZone;
277+
}
278+
279+
public void setTrustZone(final String trustZone) {
280+
this.trustZone = trustZone;
281+
}
282+
272283
@Override
273284
public boolean equals(final Object object) {
274285
if (this == object) {
@@ -290,13 +301,13 @@ public boolean equals(final Object object) {
290301
Objects.equals(properties, service.properties) && Objects.equals(tags, service.tags) &&
291302
Objects.equals(services, service.services) &&
292303
Objects.equals(releaseNotes, service.releaseNotes) &&
304+
Objects.equals(trustZone, service.trustZone) &&
293305
Objects.equals(signature, service.signature);
294306
}
295307

296308
@Override
297309
public int hashCode() {
298-
return Objects.hash(bomRef, provider, group, name, version, description, endpoints, authenticated,
299-
xTrustBoundary,
300-
data, licenses, externalReferences, properties, tags, services, releaseNotes, signature);
310+
return Objects.hash(bomRef, provider, group, name, version, description, endpoints, authenticated, signature,
311+
xTrustBoundary, trustZone, data, licenses, externalReferences, properties, tags, services, releaseNotes);
301312
}
302313
}

src/test/java/org/cyclonedx/parsers/AbstractParserTest.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ void assertVulnerabilities(final Bom bom, final Version version) {
583583
assertEquals(Status.AFFECTED, vuln.getAffects().get(0).getVersions().get(1).getStatus());
584584
}
585585

586-
void assertServices(final Bom bom) {
586+
void assertServices(final Bom bom, final Version version) {
587587
//Services
588588
List<Service> services = bom.getServices();
589589
assertEquals(1, services.size());
@@ -595,6 +595,13 @@ void assertServices(final Bom bom) {
595595
assertEquals(1, urls.size());
596596
assertEquals("https://partner.org", urls.get(0));
597597

598+
if (Version.VERSION_15.getVersion() <= version.getVersion()) {
599+
assertEquals("value", s.getTrustZone());
600+
}
601+
else {
602+
assertNull(s.getTrustZone());
603+
}
604+
598605
List<OrganizationalContact> contacts = provider.getContacts();
599606
assertEquals(1, contacts.size());
600607
OrganizationalContact contact = contacts.get(0);

src/test/java/org/cyclonedx/parsers/JsonParserTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public void testParsedObjects12Bom() throws Exception {
107107
assertEquals("(CDDL-1.0 OR GPL-2.0-with-classpath-exception)",
108108
c3.getLicenseChoice().getExpression().getValue());
109109

110-
assertServices(bom);
110+
assertServices(bom, Version.VERSION_12);
111111

112112
// Assertions for bom.dependencies
113113
assertEquals(2, bom.getDependencies().size());
@@ -126,7 +126,7 @@ public void testParsedObjects13Bom() throws Exception {
126126

127127
assertMetadata(bom, Version.VERSION_13);
128128

129-
assertServices(bom);
129+
assertServices(bom, Version.VERSION_13);
130130

131131
final List<Component> components = bom.getComponents();
132132
assertEquals(3, components.size());
@@ -171,7 +171,7 @@ public void testParsedObjects14Bom() throws Exception {
171171

172172
assertMetadata(bom.getMetadata(), Version.VERSION_14);
173173
assertComponent(bom, Version.VERSION_14);
174-
assertServices(bom);
174+
assertServices(bom, Version.VERSION_14);
175175
assertCompositions(bom, Version.VERSION_14);
176176
assertVulnerabilities(bom, Version.VERSION_14);
177177

@@ -199,7 +199,7 @@ public void testParsedObjects15Bom() throws Exception {
199199

200200
assertMetadata(bom.getMetadata(), Version.VERSION_15);
201201
assertComponent(bom, Version.VERSION_15);
202-
assertServices(bom);
202+
assertServices(bom, Version.VERSION_15);
203203
assertCompositions(bom, Version.VERSION_15);
204204
assertVulnerabilities(bom, Version.VERSION_15);
205205

src/test/java/org/cyclonedx/parsers/XmlParserTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ public void testParsedObjects12Bom() throws Exception {
289289
// Assertions for bom.components
290290
assertComponent(components.get(0), Component.Type.APPLICATION, "pkg:maven/com.acme/[email protected]?packaging=jar");
291291

292-
assertServices(bom);
292+
assertServices(bom, Version.VERSION_12);
293293

294294
// Assertions for bom.dependencies
295295
assertEquals(1, bom.getDependencies().size());
@@ -313,7 +313,7 @@ public void testParsedObjects13Bom() throws Exception {
313313

314314
assertComponent(components.get(0), Component.Type.APPLICATION, "pkg:maven/com.acme/[email protected]?packaging=jar");
315315

316-
assertServices(bom);
316+
assertServices(bom, Version.VERSION_13);
317317

318318
// Assertions for bom.dependencies
319319
assertEquals(1, bom.getDependencies().size());
@@ -334,7 +334,7 @@ public void testParsedObjects14Bom() throws Exception {
334334

335335
assertMetadata(bom.getMetadata(), Version.VERSION_14);
336336
assertComponent(bom, Version.VERSION_14);
337-
assertServices(bom);
337+
assertServices(bom, Version.VERSION_14);
338338
assertCompositions(bom, Version.VERSION_14);
339339
assertVulnerabilities(bom, Version.VERSION_14);
340340

@@ -361,7 +361,7 @@ public void testParsedObjects15Bom() throws Exception {
361361

362362
assertMetadata(bom.getMetadata(), Version.VERSION_15);
363363
assertComponent(bom, Version.VERSION_15);
364-
assertServices(bom);
364+
assertServices(bom, Version.VERSION_15);
365365
assertCompositions(bom, Version.VERSION_15);
366366
assertVulnerabilities(bom, Version.VERSION_15);
367367

src/test/resources/bom-1.5.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,7 @@
403403
],
404404
"authenticated": true,
405405
"x-trust-boundary": true,
406+
"trustZone": "value",
406407
"data": [
407408
{
408409
"flow": "inbound",

src/test/resources/bom-1.5.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,7 @@
311311
</endpoints>
312312
<authenticated>true</authenticated>
313313
<x-trust-boundary>true</x-trust-boundary>
314+
<trustZone>value</trustZone>
314315
<data>
315316
<classification flow="inbound">PII</classification>
316317
<classification flow="outbound">PIFI</classification>

0 commit comments

Comments
 (0)