Skip to content

Commit 41d0f94

Browse files
feat(sbom): add manufacturer field to CycloneDX tools metadata (#9019)
Co-authored-by: DmitriyLewen <[email protected]>
1 parent fd2bc91 commit 41d0f94

8 files changed

+48
-7
lines changed

integration/testdata/conda-cyclonedx.json.golden

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
"components": [
1111
{
1212
"type": "application",
13+
"manufacturer": {
14+
"name": "Aqua Security Software Ltd."
15+
},
1316
"group": "aquasecurity",
1417
"name": "trivy",
1518
"version": "dev"

integration/testdata/conda-environment-cyclonedx.json.golden

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
"components": [
1111
{
1212
"type": "application",
13+
"manufacturer": {
14+
"name": "Aqua Security Software Ltd."
15+
},
1316
"group": "aquasecurity",
1417
"name": "trivy",
1518
"version": "dev"

integration/testdata/fluentd-multiple-lockfiles-short.cdx.json.golden

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
"components": [
1111
{
1212
"type": "application",
13+
"manufacturer": {
14+
"name": "Aqua Security Software Ltd."
15+
},
1316
"group": "aquasecurity",
1417
"name": "trivy",
1518
"version": "dev"

integration/testdata/fluentd-multiple-lockfiles.cdx.json.golden

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
"components": [
1111
{
1212
"type": "application",
13+
"manufacturer": {
14+
"name": "Aqua Security Software Ltd."
15+
},
1316
"group": "aquasecurity",
1417
"name": "trivy",
1518
"version": "dev"

integration/testdata/npm-cyclonedx.json.golden

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
"components": [
1111
{
1212
"type": "application",
13+
"manufacturer": {
14+
"name": "Aqua Security Software Ltd."
15+
},
1316
"group": "aquasecurity",
1417
"name": "trivy",
1518
"version": "dev"

integration/testdata/pom-cyclonedx.json.golden

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
"components": [
1111
{
1212
"type": "application",
13+
"manufacturer": {
14+
"name": "Aqua Security Software Ltd."
15+
},
1316
"group": "aquasecurity",
1417
"name": "trivy",
1518
"version": "dev"

pkg/sbom/cyclonedx/marshal.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@ import (
2626
)
2727

2828
const (
29-
ToolVendor = "aquasecurity"
30-
ToolName = "trivy"
31-
Namespace = ToolVendor + ":" + ToolName + ":"
29+
ToolVendor = "aquasecurity"
30+
ToolName = "trivy"
31+
ToolManufacturer = "Aqua Security Software Ltd."
32+
Namespace = ToolVendor + ":" + ToolName + ":"
3233

3334
// https://json-schema.org/understanding-json-schema/reference/string.html#dates-and-times
3435
timeLayout = "2006-01-02T15:04:05+00:00"
@@ -88,10 +89,11 @@ func (m *Marshaler) Metadata(ctx context.Context) *cdx.Metadata {
8889
Tools: &cdx.ToolsChoice{
8990
Components: &[]cdx.Component{
9091
{
91-
Type: cdx.ComponentTypeApplication,
92-
Group: ToolVendor,
93-
Name: ToolName,
94-
Version: m.appVersion,
92+
Type: cdx.ComponentTypeApplication,
93+
Group: ToolVendor,
94+
Name: ToolName,
95+
Version: m.appVersion,
96+
Manufacturer: &cdx.OrganizationalEntity{Name: ToolManufacturer},
9597
},
9698
},
9799
},

pkg/sbom/cyclonedx/marshal_test.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,9 @@ func TestMarshaler_MarshalReport(t *testing.T) {
287287
Name: "trivy",
288288
Group: "aquasecurity",
289289
Version: "dev",
290+
Manufacturer: &cdx.OrganizationalEntity{
291+
Name: "Aqua Security Software Ltd.",
292+
},
290293
},
291294
},
292295
},
@@ -923,6 +926,9 @@ func TestMarshaler_MarshalReport(t *testing.T) {
923926
Name: "trivy",
924927
Group: "aquasecurity",
925928
Version: "dev",
929+
Manufacturer: &cdx.OrganizationalEntity{
930+
Name: "Aqua Security Software Ltd.",
931+
},
926932
},
927933
},
928934
},
@@ -1308,6 +1314,9 @@ func TestMarshaler_MarshalReport(t *testing.T) {
13081314
Name: "trivy",
13091315
Group: "aquasecurity",
13101316
Version: "dev",
1317+
Manufacturer: &cdx.OrganizationalEntity{
1318+
Name: "Aqua Security Software Ltd.",
1319+
},
13111320
},
13121321
},
13131322
},
@@ -1535,6 +1544,9 @@ func TestMarshaler_MarshalReport(t *testing.T) {
15351544
Name: "trivy",
15361545
Group: "aquasecurity",
15371546
Version: "dev",
1547+
Manufacturer: &cdx.OrganizationalEntity{
1548+
Name: "Aqua Security Software Ltd.",
1549+
},
15381550
},
15391551
},
15401552
},
@@ -1791,6 +1803,9 @@ func TestMarshaler_MarshalReport(t *testing.T) {
17911803
Name: "trivy",
17921804
Group: "aquasecurity",
17931805
Version: "dev",
1806+
Manufacturer: &cdx.OrganizationalEntity{
1807+
Name: "Aqua Security Software Ltd.",
1808+
},
17941809
},
17951810
},
17961811
},
@@ -1978,6 +1993,9 @@ func TestMarshaler_MarshalReport(t *testing.T) {
19781993
Name: "trivy",
19791994
Group: "aquasecurity",
19801995
Version: "dev",
1996+
Manufacturer: &cdx.OrganizationalEntity{
1997+
Name: "Aqua Security Software Ltd.",
1998+
},
19811999
},
19822000
},
19832001
},
@@ -2066,6 +2084,9 @@ func TestMarshaler_MarshalReport(t *testing.T) {
20662084
Name: "trivy",
20672085
Group: "aquasecurity",
20682086
Version: "dev",
2087+
Manufacturer: &cdx.OrganizationalEntity{
2088+
Name: "Aqua Security Software Ltd.",
2089+
},
20692090
},
20702091
},
20712092
},

0 commit comments

Comments
 (0)