Describe the defect
CycloneDX 2.0 has enums for many things.
Some have the case "other".
And alternatively, same enum values are open, arbitrary string.
For example
- the new
persona property - either an well-known (enums) value, or an arbitrary string.
which was already fixed
- AI ...
activity -
|
"enum": [ |
|
"design", |
|
"data-collection", |
|
"data-preparation", |
|
"training", |
|
"fine-tuning", |
|
"validation", |
|
"deployment", |
|
"inference", |
|
"other" |
|
], |
- AI ...
energySource -
|
"enum": [ |
|
"coal", |
|
"oil", |
|
"natural-gas", |
|
"nuclear", |
|
"wind", |
|
"solar", |
|
"geothermal", |
|
"hydropower", |
|
"biofuel", |
|
"unknown", |
|
"other" |
|
], |
- component ...
technique -
|
"enum": [ |
|
"source-code-analysis", |
|
"binary-analysis", |
|
"manifest-analysis", |
|
"ast-fingerprint", |
|
"hash-comparison", |
|
"instrumentation", |
|
"dynamic-analysis", |
|
"filename", |
|
"attestation", |
|
"other" |
|
] |
- component ...
type -
|
"enum": [ |
|
"source-code", |
|
"configuration", |
|
"dataset", |
|
"definition", |
|
"other" |
|
], |
- many others on cryptography ...
- many others on license ...
- many others on vulnerability...
- to be continued
When the property can be either an enums or an arbitrary string, there is no need go an emum value "other".
Goal
- Have no "other", when the enums is non-exclusive.
- At best, have them forward-compatible
Additional context
Add any other context about the problem here.
possible solution A
this is thing we are already using in other places.
- have it either a string - with enum values
- or have it an object with
name and description
like here
|
"oneOf": [ |
|
{ |
|
"title": "Pre-Defined Kind", |
|
"type": "string", |
|
"enum": [ |
|
"software-system", |
|
"hardware-system", |
|
"service-account", |
|
"machine-identity", |
|
"automation", |
|
"agent", |
|
"bot", |
|
"oracle", |
|
"smart-contract", |
|
"device", |
|
"robot" |
|
], |
|
"meta:enum": { |
|
"software-system": "Application, service, or platform that performs actions as itself.", |
|
"hardware-system": "Physical device or appliance that performs actions. Includes vehicles, drones, satellites, medical devices, network equipment, and industrial controllers unless a more specific kind applies.", |
|
"service-account": "Non-human identity used by automation to authenticate.", |
|
"machine-identity": "Cryptographic identity such as a certificate principal or workload identity.", |
|
"automation": "Pipeline, job, or scheduled task that performs actions deterministically.", |
|
"agent": "Autonomous or semi-autonomous agent that can plan and execute. Includes AI agents.", |
|
"bot": "Scripted automation that interacts with an interface. Includes chatbots, robotic process automation bots, and scraping bots.", |
|
"oracle": "External data feed or oracle, including blockchain oracles that bridge off-chain data into on-chain systems.", |
|
"smart-contract": "On-chain program that executes deterministically.", |
|
"device": "Physical end user device such as a phone or IoT device acting as a party in its own right.", |
|
"robot": "Physical robot or autonomous mechanical system. For software-only counterparts, see `bot`, `agent`, or `automation`." |
|
} |
|
}, |
|
{ |
|
"title": "Custom Kind", |
|
"type": "object", |
|
"required": [ "name" ], |
|
"additionalProperties": false, |
|
"properties": { |
|
"name": { |
|
"type": "string", |
|
"minLength": 1, |
|
"title": "Name", |
|
"description": "The name of the custom kind." |
|
}, |
|
"description": { |
|
"type": "string", |
|
"title": "Description", |
|
"description": "A description of the custom kind." |
|
} |
|
} |
|
} |
|
] |
{
"type": "object",
"properties": {
"foo": {
"oneOf": [
{
"title": "Pre-Defined Foo",
"type": "string",
"enum": [
"well-known-1",
"well-known-2",
"well-known-3"
],
"meta:enum": {
"well-known-1": "the description what this means",
"well-known-2": "the description what this other value means" ,
"well-known-3": "..."
}
},
{
"title": "Custom Foo",
"type": "object",
"required": [ "name" ],
"additionalProperties": false,
"properties": {
"name": {
"type": "string",
"minLength": 1,
"title": "Name",
"description": "The name of the custom foo."
},
"description": {
"type": "string",
"title": "Description",
"description": "A description of the custom foo."
}
}
}
]
}
}
}
possible solution B
{
"type": "object",
"properties": {
"foo": {
"type": "string",
"anyOf": [
{
"$comment": "well-known values",
"enum": [
"well-known-1",
"well-known-2",
"well-known-3"
],
"meta:enum": {
"well-known-1": "the description what this means",
"well-known-2": "the description what this other value means" ,
"well-known-3": "..."
}
},
{
"$comment": "custom value",
"type": "string",
"minLength": 1
}
]
}
}
}
Preferably,
we might even go with a prefix on the "custom"("other"), tho prevent collisions when adding new values with well-defined values
{
"type": "object",
"properties": {
"foo": {
"type": "string",
"anyOf": [
{
"$comment": "well-known values",
"enum": [
"well-known-1",
"well-known-2",
"well-known-3"
],
"meta:enum": {
"well-known-1": "the description what this means",
"well-known-2": "the description what this other value means" ,
"well-known-3": "..."
}
},
{
"$comment": "custom - prefixed with 'custom: '",
"type": "string"
"pattern": "^custom: (.+)$"
}
]
}
}
}
possible solution C
... to be discussed ...
maybe something like
{
"type": "object",
"properties": {
"category": { "type": "string", "enum": ["red", "green", "blue", "custom"] },
"categoryCustom": { "type": "string", "minLength": 1 }
},
"required": ["category"],
"allOf": [
{
"if": { "properties": { "category": { "const": "custom" } }, "required": ["category"] },
"then": { "required": ["categoryCustom"] },
"else": { "not": { "required": ["categoryCustom"] } }
}
]
}
Describe the defect
CycloneDX 2.0 has enums for many things.
Some have the case "other".
And alternatively, same enum values are open, arbitrary string.
For example
personaproperty - either an well-known (enums) value, or an arbitrary string.which was already fixed
activity-specification/schema/2.0/model/cyclonedx-ai-modelcard-2.0.schema.json
Lines 248 to 258 in bbbcaec
energySource-specification/schema/2.0/model/cyclonedx-ai-modelcard-2.0.schema.json
Lines 383 to 395 in bbbcaec
technique-specification/schema/2.0/model/cyclonedx-component-2.0.schema.json
Lines 567 to 578 in bbbcaec
type-specification/schema/2.0/model/cyclonedx-component-2.0.schema.json
Lines 631 to 637 in bbbcaec
When the property can be either an enums or an arbitrary string, there is no need go an emum value "other".
Goal
Additional context
Add any other context about the problem here.
possible solution A
this is thing we are already using in other places.
nameanddescriptionlike here
specification/schema/2.0/model/cyclonedx-party-2.0.schema.json
Lines 496 to 546 in 2a86067
{ "type": "object", "properties": { "foo": { "oneOf": [ { "title": "Pre-Defined Foo", "type": "string", "enum": [ "well-known-1", "well-known-2", "well-known-3" ], "meta:enum": { "well-known-1": "the description what this means", "well-known-2": "the description what this other value means" , "well-known-3": "..." } }, { "title": "Custom Foo", "type": "object", "required": [ "name" ], "additionalProperties": false, "properties": { "name": { "type": "string", "minLength": 1, "title": "Name", "description": "The name of the custom foo." }, "description": { "type": "string", "title": "Description", "description": "A description of the custom foo." } } } ] } } }possible solution B
{ "type": "object", "properties": { "foo": { "type": "string", "anyOf": [ { "$comment": "well-known values", "enum": [ "well-known-1", "well-known-2", "well-known-3" ], "meta:enum": { "well-known-1": "the description what this means", "well-known-2": "the description what this other value means" , "well-known-3": "..." } }, { "$comment": "custom value", "type": "string", "minLength": 1 } ] } } }Preferably,
we might even go with a prefix on the "custom"("other"), tho prevent collisions when adding new values with well-defined values
{ "type": "object", "properties": { "foo": { "type": "string", "anyOf": [ { "$comment": "well-known values", "enum": [ "well-known-1", "well-known-2", "well-known-3" ], "meta:enum": { "well-known-1": "the description what this means", "well-known-2": "the description what this other value means" , "well-known-3": "..." } }, { "$comment": "custom - prefixed with 'custom: '", "type": "string" "pattern": "^custom: (.+)$" } ] } } }possible solution C
... to be discussed ...
maybe something like
{ "type": "object", "properties": { "category": { "type": "string", "enum": ["red", "green", "blue", "custom"] }, "categoryCustom": { "type": "string", "minLength": 1 } }, "required": ["category"], "allOf": [ { "if": { "properties": { "category": { "const": "custom" } }, "required": ["category"] }, "then": { "required": ["categoryCustom"] }, "else": { "not": { "required": ["categoryCustom"] } } } ] }