Skip to content

Commit 808e35e

Browse files
authored
Merge pull request #126 from CycloneDX/spec-v1.3
Add spec v1.3 support for XML and JSON formats
2 parents 54a2a13 + 004081d commit 808e35e

File tree

55 files changed

+3600
-100
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+3600
-100
lines changed

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
/.vs/
22
/.vscode/
3+
/.idea/
34
bin/
45
obj/
56
packages/
67
coverage-report/
78
coverage.cobertura.xml
8-
*/__snapshots__/__mismatch__/
9+
*/__snapshots__/__mismatch__/
10+
*.user

cyclonedx.tests/ConvertTests.cs

+10-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,15 @@ public class ConvertTests
2424
[InlineData("bom-1.2.xml", InputFormat.xml, "bom.xml", Commands.ConvertOutputFormat.xml_v1_2)]
2525
[InlineData("bom-1.2.json", InputFormat.autodetect, "bom.json", Commands.ConvertOutputFormat.autodetect)]
2626
[InlineData("bom-1.2.json", InputFormat.json, "bom.json", Commands.ConvertOutputFormat.autodetect)]
27-
[InlineData("bom-1.2.json", InputFormat.json, "bom.json", Commands.ConvertOutputFormat.json)]
27+
[InlineData("bom-1.2.json", InputFormat.json, "bom.json", Commands.ConvertOutputFormat.json_v1_2)]
28+
[InlineData("bom-1.3.xml", InputFormat.autodetect, "bom.xml", Commands.ConvertOutputFormat.autodetect)]
29+
[InlineData("bom-1.3.xml", InputFormat.xml, "bom.xml", Commands.ConvertOutputFormat.autodetect)]
30+
[InlineData("bom-1.3.xml", InputFormat.xml, "bom.xml", Commands.ConvertOutputFormat.xml)]
31+
[InlineData("bom-1.3.xml", InputFormat.xml, "bom.xml", Commands.ConvertOutputFormat.xml_v1_3)]
32+
[InlineData("bom-1.3.json", InputFormat.autodetect, "bom.json", Commands.ConvertOutputFormat.autodetect)]
33+
[InlineData("bom-1.3.json", InputFormat.json, "bom.json", Commands.ConvertOutputFormat.autodetect)]
34+
[InlineData("bom-1.3.json", InputFormat.json, "bom.json", Commands.ConvertOutputFormat.json)]
35+
[InlineData("bom-1.3.json", InputFormat.json, "bom.json", Commands.ConvertOutputFormat.json_v1_3)]
2836
[InlineData("bom.csv", InputFormat.autodetect, "bom.csv", Commands.ConvertOutputFormat.autodetect)]
2937
[InlineData("bom.csv", InputFormat.csv, "bom.csv", Commands.ConvertOutputFormat.autodetect)]
3038
[InlineData("bom.csv", InputFormat.csv, "bom.csv", Commands.ConvertOutputFormat.csv)]
@@ -37,7 +45,7 @@ public async Task Convert(string inputFilename, InputFormat inputFormat, string
3745
Path.Combine("Resources", inputFilename),
3846
fullOutputPath,
3947
inputFormat,
40-
Commands.ConvertOutputFormat.autodetect);
48+
outputFormat);
4149

4250
Assert.Equal(0, exitCode);
4351
var bom = File.ReadAllText(fullOutputPath);

cyclonedx.tests/CsvSerializerTests.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public void SerializationTests(string filename)
2424
{
2525
var resourceFilename = Path.Join("Resources", filename + "-1.2.xml");
2626
var inputBomString = File.ReadAllText(resourceFilename);
27-
var bom = XmlBomDeserializer.Deserialize_v1_2(inputBomString);
27+
var bom = Xml.Deserializer.Deserialize(inputBomString);
2828

2929
var bomCsv = CsvSerializer.Serialize(bom);
3030

@@ -52,7 +52,7 @@ public void DeserializationTests(string filename)
5252

5353
var bom = CsvSerializer.Deserialize(inputBomString);
5454

55-
var bomXml = XmlBomSerializer.Serialize(bom);
55+
var bomXml = Xml.Serializer.Serialize(bom);
5656

5757
Snapshot.Match(bomXml, SnapshotNameExtension.Create(filename));
5858
}
+177
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
{
2+
"bomFormat": "CycloneDX",
3+
"specVersion": "1.3",
4+
"serialNumber": "urn:uuid:3e671687-395b-41f5-a30f-a58921a69b79",
5+
"version": 1,
6+
"metadata": {
7+
"timestamp": "2020-04-13T20:20:39+00:00",
8+
"tools": [
9+
{
10+
"vendor": "Awesome Vendor",
11+
"name": "Awesome Tool",
12+
"version": "9.1.2",
13+
"hashes": [
14+
{
15+
"alg": "SHA-1",
16+
"content": "25ed8e31b995bb927966616df2a42b979a2717f0"
17+
},
18+
{
19+
"alg": "SHA-256",
20+
"content": "a74f733635a19aefb1f73e5947cef59cd7440c6952ef0f03d09d974274cbd6df"
21+
}
22+
]
23+
}
24+
],
25+
"authors": [
26+
{
27+
"name": "Samantha Wright",
28+
"email": "[email protected]",
29+
"phone": "800-555-1212"
30+
}
31+
],
32+
"component": {
33+
"type": "application",
34+
"author": "Acme Super Heros",
35+
"name": "Acme Application",
36+
"version": "9.1.1",
37+
"swid": {
38+
"tagId": "swidgen-242eb18a-503e-ca37-393b-cf156ef09691_9.1.1",
39+
"name": "Acme Application",
40+
"version": "9.1.1",
41+
"text": {
42+
"contentType": "text/xml",
43+
"encoding": "base64",
44+
"content": "PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiID8+CjxTb2Z0d2FyZUlkZW50aXR5IHhtbDpsYW5nPSJFTiIgbmFtZT0iQWNtZSBBcHBsaWNhdGlvbiIgdmVyc2lvbj0iOS4xLjEiIAogdmVyc2lvblNjaGVtZT0ibXVsdGlwYXJ0bnVtZXJpYyIgCiB0YWdJZD0ic3dpZGdlbi1iNTk1MWFjOS00MmMwLWYzODItM2YxZS1iYzdhMmE0NDk3Y2JfOS4xLjEiIAogeG1sbnM9Imh0dHA6Ly9zdGFuZGFyZHMuaXNvLm9yZy9pc28vMTk3NzAvLTIvMjAxNS9zY2hlbWEueHNkIj4gCiB4bWxuczp4c2k9Imh0dHA6Ly93d3cudzMub3JnLzIwMDEvWE1MU2NoZW1hLWluc3RhbmNlIiAKIHhzaTpzY2hlbWFMb2NhdGlvbj0iaHR0cDovL3N0YW5kYXJkcy5pc28ub3JnL2lzby8xOTc3MC8tMi8yMDE1LWN1cnJlbnQvc2NoZW1hLnhzZCBzY2hlbWEueHNkIiA+CiAgPE1ldGEgZ2VuZXJhdG9yPSJTV0lEIFRhZyBPbmxpbmUgR2VuZXJhdG9yIHYwLjEiIC8+IAogIDxFbnRpdHkgbmFtZT0iQWNtZSwgSW5jLiIgcmVnaWQ9ImV4YW1wbGUuY29tIiByb2xlPSJ0YWdDcmVhdG9yIiAvPiAKPC9Tb2Z0d2FyZUlkZW50aXR5Pg=="
45+
}
46+
}
47+
},
48+
"manufacture": {
49+
"name": "Acme, Inc.",
50+
"url": [
51+
"https://example.com"
52+
],
53+
"contact": [
54+
{
55+
"name": "Acme Professional Services",
56+
"email": "[email protected]"
57+
}
58+
]
59+
},
60+
"supplier": {
61+
"name": "Acme, Inc.",
62+
"url": [
63+
"https://example.com"
64+
],
65+
"contact": [
66+
{
67+
"name": "Acme Distribution",
68+
"email": "[email protected]"
69+
}
70+
]
71+
}
72+
},
73+
"components": [
74+
{
75+
"bom-ref": "pkg:npm/acme/[email protected]",
76+
"type": "library",
77+
"publisher": "Acme Inc",
78+
"group": "com.acme",
79+
"name": "tomcat-catalina",
80+
"version": "9.0.14",
81+
"hashes": [
82+
{
83+
"alg": "MD5",
84+
"content": "3942447fac867ae5cdb3229b658f4d48"
85+
},
86+
{
87+
"alg": "SHA-1",
88+
"content": "e6b1000b94e835ffd37f4c6dcbdad43f4b48a02a"
89+
},
90+
{
91+
"alg": "SHA-256",
92+
"content": "f498a8ff2dd007e29c2074f5e4b01a9a01775c3ff3aeaf6906ea503bc5791b7b"
93+
},
94+
{
95+
"alg": "SHA-512",
96+
"content": "e8f33e424f3f4ed6db76a482fde1a5298970e442c531729119e37991884bdffab4f9426b7ee11fccd074eeda0634d71697d6f88a460dce0ac8d627a29f7d1282"
97+
}
98+
],
99+
"licenses": [
100+
{
101+
"license": {
102+
"id": "Apache-2.0",
103+
"text": {
104+
"contentType": "text/plain",
105+
"encoding": "base64",
106+
"content": "License text here"
107+
},
108+
"url": "https://www.apache.org/licenses/LICENSE-2.0.txt"
109+
}
110+
}
111+
],
112+
"purl": "pkg:npm/acme/[email protected]",
113+
"pedigree": {
114+
"ancestors": [
115+
{
116+
"type": "library",
117+
"publisher": "Acme Inc",
118+
"group": "com.acme",
119+
"name": "tomcat-catalina",
120+
"version": "9.0.14"
121+
},
122+
{
123+
"type": "library",
124+
"publisher": "Acme Inc",
125+
"group": "com.acme",
126+
"name": "tomcat-catalina",
127+
"version": "9.0.14"
128+
}
129+
],
130+
"commits": [
131+
{
132+
"uid": "123",
133+
"url": "",
134+
"author": {
135+
"timestamp": "2018-11-13T20:20:39+00:00",
136+
"name": "",
137+
"email": ""
138+
}
139+
}
140+
]
141+
}
142+
},
143+
{
144+
"type": "library",
145+
"supplier": {
146+
"name": "Example, Inc.",
147+
"url": [
148+
"https://example.com",
149+
"https://example.net"
150+
],
151+
"contact": [
152+
{
153+
"name": "Example Support AMER Distribution",
154+
"email": "[email protected]",
155+
"phone": "800-555-1212"
156+
},
157+
{
158+
"name": "Example Support APAC",
159+
"email": "[email protected]"
160+
}
161+
]
162+
},
163+
"author": "Example Super Heros",
164+
"group": "org.example",
165+
"name": "mylibrary",
166+
"version": "1.0.0"
167+
}
168+
],
169+
"dependencies": [
170+
{
171+
"ref": "pkg:npm/acme/[email protected]",
172+
"dependsOn": [
173+
"pkg:npm/acme/[email protected]"
174+
]
175+
}
176+
]
177+
}

cyclonedx.tests/Resources/bom-1.3.xml

+181
Large diffs are not rendered by default.

cyclonedx.tests/__snapshots__/ConvertTests.Convert_bom-1.0.xml_autodetect_bom.xml_autodetect.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<bom xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" version="1" xmlns="http://cyclonedx.org/schema/bom/1.2">
2+
<bom xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" version="1" xmlns="http://cyclonedx.org/schema/bom/1.3">
33
<components>
44
<component type="application">
55
<group>org.example</group>

cyclonedx.tests/__snapshots__/ConvertTests.Convert_bom-1.0.xml_xml_bom.xml_autodetect.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<bom xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" version="1" xmlns="http://cyclonedx.org/schema/bom/1.2">
2+
<bom xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" version="1" xmlns="http://cyclonedx.org/schema/bom/1.3">
33
<components>
44
<component type="application">
55
<group>org.example</group>

cyclonedx.tests/__snapshots__/ConvertTests.Convert_bom-1.0.xml_xml_bom.xml_xml_v1_1.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<bom xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" version="1" xmlns="http://cyclonedx.org/schema/bom/1.2">
2+
<bom xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" version="1" xmlns="http://cyclonedx.org/schema/bom/1.1">
33
<components>
44
<component type="application">
55
<group>org.example</group>

cyclonedx.tests/__snapshots__/ConvertTests.Convert_bom-1.1.xml_autodetect_bom.xml_autodetect.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<bom xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" serialNumber="urn:uuid:3e671687-395b-41f5-a30f-a58921a69b79" version="1" xmlns="http://cyclonedx.org/schema/bom/1.2">
2+
<bom xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" serialNumber="urn:uuid:3e671687-395b-41f5-a30f-a58921a69b79" version="1" xmlns="http://cyclonedx.org/schema/bom/1.3">
33
<components>
44
<component type="application">
55
<publisher>Acme Inc</publisher>

cyclonedx.tests/__snapshots__/ConvertTests.Convert_bom-1.1.xml_xml_bom.xml_autodetect.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<bom xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" serialNumber="urn:uuid:3e671687-395b-41f5-a30f-a58921a69b79" version="1" xmlns="http://cyclonedx.org/schema/bom/1.2">
2+
<bom xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" serialNumber="urn:uuid:3e671687-395b-41f5-a30f-a58921a69b79" version="1" xmlns="http://cyclonedx.org/schema/bom/1.3">
33
<components>
44
<component type="application">
55
<publisher>Acme Inc</publisher>

cyclonedx.tests/__snapshots__/ConvertTests.Convert_bom-1.1.xml_xml_bom.xml_xml_v1_1.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<bom xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" serialNumber="urn:uuid:3e671687-395b-41f5-a30f-a58921a69b79" version="1" xmlns="http://cyclonedx.org/schema/bom/1.2">
2+
<bom xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" serialNumber="urn:uuid:3e671687-395b-41f5-a30f-a58921a69b79" version="1" xmlns="http://cyclonedx.org/schema/bom/1.1">
33
<components>
44
<component type="application">
55
<publisher>Acme Inc</publisher>

0 commit comments

Comments
 (0)