Repository navigation
Description
in CycloneDX 1.x we introduced refType.
and we made them formally defined:
specification/schema/bom-1.7.schema.json
Lines 553 to 559 in fac1ff6
| "refType": { | |
| "title": "BOM Reference", | |
| "description": "Identifier for referable and therefore interlinkable elements.\nValue SHOULD not start with the BOM-Link intro 'urn:cdx:' to avoid conflicts with BOM-Links.", | |
| "type": "string", | |
| "minLength": 1, | |
| "$comment": "TODO (breaking change): add a format constraint that prevents the value from starting with 'urn:cdx:'" | |
| }, |
in addition, we defined links
- in-document elements:
refLinkType-specification/schema/bom-1.7.schema.json
Lines 560 to 564 in fac1ff6
"refLinkType": { "title": "BOM Reference", "description": "Descriptor for an element identified by the attribute 'bom-ref' in the same BOM document.\nIn contrast to `bomLinkElementType`.", "$ref": "#/definitions/refType" }, - outside-document documents
bomLinkDocumentType-specification/schema/bom-1.7.schema.json
Lines 565 to 572 in fac1ff6
"bomLinkDocumentType": { "title": "BOM-Link Document", "description": "Descriptor for another BOM document. See https://cyclonedx.org/capabilities/bomlink/", "type": "string", "format": "iri-reference", "pattern": "^urn:cdx:[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/[1-9][0-9]*$", "$comment": "part of the pattern is based on `bom.serialNumber`'s pattern" }, - outside-document elements:
bomLinkElementType-specification/schema/bom-1.7.schema.json
Lines 573 to 580 in fac1ff6
"bomLinkElementType": { "title": "BOM-Link Element", "description": "Descriptor for an element in a BOM document. See https://cyclonedx.org/capabilities/bomlink/", "type": "string", "format": "iri-reference", "pattern": "^urn:cdx:[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/[1-9][0-9]*#.+$", "$comment": "part of the pattern is based on `bom.serialNumber`'s pattern" }, - outside-document anything:
bomLink-specification/schema/bom-1.7.schema.json
Lines 581 to 593 in fac1ff6
"bomLink": { "title": "BOM-Link", "anyOf": [ { "title": "BOM-Link Document", "$ref": "#/definitions/bomLinkDocumentType" }, { "title": "BOM-Link Element", "$ref": "#/definitions/bomLinkElementType" } ] },
For compatibility reasons, we did not enforce a pattern on the original refType.
We also have a standing issue: the value of a refType/refLinkType could be a semantical bomLink value .
This would cause an intentional in-document link to point to an outside-document ...
With CycloneDX 2.0 allowing us to introduce breaking changes, we have the option to change this:
goal
Have refType prevents the value from starting with 'urn:cdx:'.
constraints
use only simple (standard) regex -- https://json-schema.org/understanding-json-schema/reference/regular_expressions
[...] recommended that you stick to the subset of that syntax described below.
proposed solution:
{
"definitions": {
"refType": {
// ...
"type": "string",
"minLength": 1,
"pattern": "^(?!urn:cdx:)" // no additional `.+` needed, minLength does this for us ...
}
}
}possible followup
we need to review every usage of refLinkType, and see if the thing is really intended to link only to in-document elements, or also to outside-document elements (bomLinkElementType)
in these cases, we should be using
{
// ...
"ref": {
"anyOf": [
{
"title": "Ref",
"$ref": "cyclonedx-common-2.0.schema.json#/$defs/refLinkType"
},
{
"title": "BOM-Link Element",
"$ref": "cyclonedx-common-2.0.schema.json#/$defs/bomLinkElementType"
}
],
"title": "Reference",
"type": "string",
"description": "References a data component by the components bom-ref attribute"
}
}
Activity