From c418c2a27d1723de0b03766f90fff0466c293679 Mon Sep 17 00:00:00 2001 From: Jan Kowalleck Date: Fri, 9 Feb 2024 13:18:55 +0100 Subject: [PATCH 1/3] tests: test data and examples for valid and invalid property Signed-off-by: Jan Kowalleck --- .../resources/1.6/valid-properties-1.6.json | 36 ++++++++++++++----- .../1.6/valid-properties-1.6.textproto | 36 ++++++++++++++----- .../resources/1.6/valid-properties-1.6.xml | 8 +++-- 3 files changed, 62 insertions(+), 18 deletions(-) diff --git a/tools/src/test/resources/1.6/valid-properties-1.6.json b/tools/src/test/resources/1.6/valid-properties-1.6.json index 237f7fe22..68c47f86f 100644 --- a/tools/src/test/resources/1.6/valid-properties-1.6.json +++ b/tools/src/test/resources/1.6/valid-properties-1.6.json @@ -9,10 +9,6 @@ "name": "Foo", "value": "Bar" }, - { - "name": "Foo", - "value": "You" - }, { "name": "Foo", "value": "Two" @@ -20,6 +16,9 @@ { "name": "Bar", "value": "Foo" + }, + { + "name": "value-is-optional" } ] }, @@ -37,10 +36,6 @@ "name": "Foo", "value": "Bar" }, - { - "name": "Foo", - "value": "You" - }, { "name": "Foo", "value": "Two" @@ -48,6 +43,9 @@ { "name": "Bar", "value": "Foo" + }, + { + "name": "value-is-optional" } ] } @@ -57,6 +55,17 @@ { "name": "Foo", "value": "Bar" + }, + { + "name": "Foo", + "value": "Two" + }, + { + "name": "Bar", + "value": "Foo" + }, + { + "name": "value-is-optional" } ] } @@ -73,6 +82,17 @@ { "name": "Foo", "value": "Bar" + }, + { + "name": "Foo", + "value": "Two" + }, + { + "name": "Bar", + "value": "Foo" + }, + { + "name": "value-is-optional" } ] } diff --git a/tools/src/test/resources/1.6/valid-properties-1.6.textproto b/tools/src/test/resources/1.6/valid-properties-1.6.textproto index 437799854..3f1c2ac6d 100644 --- a/tools/src/test/resources/1.6/valid-properties-1.6.textproto +++ b/tools/src/test/resources/1.6/valid-properties-1.6.textproto @@ -6,10 +6,6 @@ metadata { name: "Foo" value: "Bar" } - properties { - name: "Foo" - value: "You" - } properties { name: "Foo" value: "Two" @@ -18,6 +14,9 @@ metadata { name: "Bar" value: "Foo" } + properties { + name: "value-is-optional" + } } components { type: CLASSIFICATION_LIBRARY @@ -30,10 +29,6 @@ components { name: "Foo" value: "Bar" } - properties { - name: "Foo" - value: "You" - } properties { name: "Foo" value: "Two" @@ -42,12 +37,26 @@ components { name: "Bar" value: "Foo" } + properties { + name: "value-is-optional" + } } } properties { name: "Foo" value: "Bar" } + properties { + name: "Foo" + value: "Two" + } + properties { + name: "Bar" + value: "Foo" + } + properties { + name: "value-is-optional" + } } services { bom_ref: "b2a46a4b-8367-4bae-9820-95557cfe03a8" @@ -58,4 +67,15 @@ services { name: "Foo" value: "Bar" } + properties { + name: "Foo" + value: "Two" + } + properties { + name: "Bar" + value: "Foo" + } + properties { + name: "value-is-optional" + } } diff --git a/tools/src/test/resources/1.6/valid-properties-1.6.xml b/tools/src/test/resources/1.6/valid-properties-1.6.xml index 32cd224cd..ac03d4b89 100644 --- a/tools/src/test/resources/1.6/valid-properties-1.6.xml +++ b/tools/src/test/resources/1.6/valid-properties-1.6.xml @@ -3,9 +3,9 @@ Bar - You Two Foo + @@ -17,15 +17,17 @@ Apache-2.0 Bar - You Two Foo + Bar + Two Foo + @@ -38,7 +40,9 @@ Bar + Two Foo + From e6ea842ea49d7b9a50951220ce86a24a56c5971e Mon Sep 17 00:00:00 2001 From: Jan Kowalleck Date: Fri, 9 Feb 2024 13:19:00 +0100 Subject: [PATCH 2/3] tests: test data and examples for valid and invalid property Signed-off-by: Jan Kowalleck --- .../resources/1.6/invalid-properties-1.6.json | 68 +++++++++++++++++++ .../1.6/invalid-properties-1.6.textproto | 45 ++++++++++++ .../resources/1.6/invalid-properties-1.6.xml | 41 +++++++++++ 3 files changed, 154 insertions(+) create mode 100644 tools/src/test/resources/1.6/invalid-properties-1.6.json create mode 100644 tools/src/test/resources/1.6/invalid-properties-1.6.textproto create mode 100644 tools/src/test/resources/1.6/invalid-properties-1.6.xml diff --git a/tools/src/test/resources/1.6/invalid-properties-1.6.json b/tools/src/test/resources/1.6/invalid-properties-1.6.json new file mode 100644 index 000000000..069850353 --- /dev/null +++ b/tools/src/test/resources/1.6/invalid-properties-1.6.json @@ -0,0 +1,68 @@ +{ + "bomFormat": "CycloneDX", + "specVersion": "1.6", + "serialNumber": "urn:uuid:bcb403ae-91fa-436e-bc93-84d1078cdeed", + "version": 1, + "metadata": { + "properties": [ + { + "value": "missing a name" + }, + { + "unexpected-property": "foo" + }, + {} + ] + }, + "components": [ + { + "type": "library", + "name": "acme-library", + "version": "1.0.0", + "licenses": [ + { + "license": { + "id": "Apache-2.0", + "properties": [ + { + "value": "missing a name" + }, + { + "unexpected-property": "foo" + }, + {} + ] + } + } + ], + "properties": [ + { + "value": "missing a name" + }, + { + "unexpected-property": "foo" + }, + {} + ] + } + ], + "services": [ + { + "bom-ref": "b2a46a4b-8367-4bae-9820-95557cfe03a8", + "group": "org.partner", + "name": "Stock ticker service", + "endpoints": [ + "https://partner.org/api/v1/stock" + ], + "properties": [ + { + "value": "missing a name" + }, + { + "unexpected-property": "foo" + }, + {} + ] + } + ] +} diff --git a/tools/src/test/resources/1.6/invalid-properties-1.6.textproto b/tools/src/test/resources/1.6/invalid-properties-1.6.textproto new file mode 100644 index 000000000..9afebf51a --- /dev/null +++ b/tools/src/test/resources/1.6/invalid-properties-1.6.textproto @@ -0,0 +1,45 @@ +spec_version: "1.6" +version: 1 +serial_number: "urn:uuid:bcb403ae-91fa-436e-bc93-84d1078cdeed" +metadata { + properties { + value: "missing a name" + } + properties { + # no name and no value + } +} +components { + type: CLASSIFICATION_LIBRARY + name: "acme-library" + version: "1.0.0" + licenses { + license { + id: "Apache-2.0" + properties { + value: "missing a name" + } + properties { + # no name and no value + } + } + } + properties { + value: "missing a name" + } + properties { + # no name and no value + } +} +services { + bom_ref: "b2a46a4b-8367-4bae-9820-95557cfe03a8" + group: "org.partner" + name: "Stock ticker service" + endpoints: "https://partner.org/api/v1/stock" + properties { + value: "missing a name" + } + properties { + # no name and no value + } +} diff --git a/tools/src/test/resources/1.6/invalid-properties-1.6.xml b/tools/src/test/resources/1.6/invalid-properties-1.6.xml new file mode 100644 index 000000000..9c54127f0 --- /dev/null +++ b/tools/src/test/resources/1.6/invalid-properties-1.6.xml @@ -0,0 +1,41 @@ + + + + + missing a name + + + + + + acme-library + 1.0.0 + + + Apache-2.0 + + missing a name + + + + + + missing a name + + + + + + + org.partner + Stock ticker service + + https://partner.org/api/v1/stock + + + missing a name + + + + + From 09819671005b06d8790b4a501737f7a7efcb38c2 Mon Sep 17 00:00:00 2001 From: Jan Kowalleck Date: Fri, 9 Feb 2024 13:32:22 +0100 Subject: [PATCH 3/3] fix: in JSON, CycloneDX property has mandatory name and no additionalProperties Signed-off-by: Jan Kowalleck --- schema/bom-1.6.schema.json | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/schema/bom-1.6.schema.json b/schema/bom-1.6.schema.json index 695b1d2d4..3765d4da8 100644 --- a/schema/bom-1.6.schema.json +++ b/schema/bom-1.6.schema.json @@ -2218,6 +2218,9 @@ "type": "object", "title": "Lightweight name-value pair", "description": "Provides the ability to document properties in a name-value store. This provides flexibility to include data not officially supported in the standard without having to use additional namespaces or create extensions. Unlike key-value stores, properties support duplicate names, each potentially having different values. Property names of interest to the general public are encouraged to be registered in the [CycloneDX Property Taxonomy](https://github.com/CycloneDX/cyclonedx-property-taxonomy). Formal registration is OPTIONAL.", + "required": [ + "name" + ], "properties": { "name": { "type": "string", @@ -2229,7 +2232,8 @@ "title": "Value", "description": "The value of the property." } - } + }, + "additionalProperties": false }, "localeType": { "type": "string",