From 3f18548431e10a39c28292c976a277ebd57d3033 Mon Sep 17 00:00:00 2001 From: Srinivas Chippagiri Date: Wed, 11 Nov 2026 17:04:12 -0800 Subject: [PATCH 1/3] fix(2.0): share one ISO 8601 duration definition Add a duration def to common and use it for blueprint reviewFrequency and the risk timeframe, downtime, recovery and horizon properties. The pattern accepts the time part that reviewFrequency was missing, rejects weeks mixed with other designators, and timeframe and horizon now have a pattern at all. Signed-off-by: Srinivas Chippagiri --- .../cyclonedx-blueprint-2.0.schema.json | 5 ++--- .../modules/cyclonedx-common-2.0.schema.json | 13 ++++++++++++ .../modules/cyclonedx-risk-2.0.schema.json | 10 ++++----- ...-blueprint-review-frequency-weeks-2.0.json | 21 +++++++++++++++++++ ...invalid-risk-likelihood-timeframe-2.0.json | 18 ++++++++++++++++ .../valid-blueprint-review-frequency-2.0.json | 21 +++++++++++++++++++ 6 files changed, 79 insertions(+), 9 deletions(-) create mode 100644 tools/src/test/resources/2.0/invalid-blueprint-review-frequency-weeks-2.0.json create mode 100644 tools/src/test/resources/2.0/invalid-risk-likelihood-timeframe-2.0.json create mode 100644 tools/src/test/resources/2.0/valid-blueprint-review-frequency-2.0.json diff --git a/schema/2.0/modules/cyclonedx-blueprint-2.0.schema.json b/schema/2.0/modules/cyclonedx-blueprint-2.0.schema.json index 178ba9aa6..6d2cd4209 100644 --- a/schema/2.0/modules/cyclonedx-blueprint-2.0.schema.json +++ b/schema/2.0/modules/cyclonedx-blueprint-2.0.schema.json @@ -338,10 +338,9 @@ "description": "When the blueprint expires." }, "reviewFrequency": { - "type": "string", + "$ref": "cyclonedx-common-2.0.schema.json#/$defs/duration", "title": "Review Frequency", - "pattern": "^P(?!$)(\\d+Y)?(\\d+M)?(\\d+W)?(\\d+D)?$", - "description": "ISO 8601 duration for review frequency (e.g., P3M for quarterly)." + "description": "How often the blueprint is reviewed, as an [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) duration, for example P3M for quarterly." } } }, diff --git a/schema/2.0/modules/cyclonedx-common-2.0.schema.json b/schema/2.0/modules/cyclonedx-common-2.0.schema.json index 30d302c8d..a09721028 100644 --- a/schema/2.0/modules/cyclonedx-common-2.0.schema.json +++ b/schema/2.0/modules/cyclonedx-common-2.0.schema.json @@ -680,6 +680,19 @@ "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$", "description": "An RFC 3339-compliant UTC timestamp using Zulu time (i.e., ending with 'Z'). The format shall be 'YYYY-MM-DDTHH:MM:SSZ' or include optional fractional seconds, e.g., 'YYYY-MM-DDTHH:MM:SS.sssZ'. Offsets such as '+00:00' are not allowed." }, + "duration": { + "type": "string", + "title": "Duration", + "pattern": "^P(?!$)((\\d+Y)?(\\d+M)?(\\d+D)?(T(?=\\d)(\\d+H)?(\\d+M)?(\\d+(\\.\\d+)?S)?)?|\\d+W)$", + "description": "An [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) duration, such as 'P1Y', 'P3M', 'P1DT12H' or 'PT30M'. Weeks shall not be combined with other designators, so 'P2W' is valid but 'P1M2W' is not. Only the seconds may have a decimal fraction, e.g., 'PT0.5S'.", + "examples": [ + "P1Y", + "P3M", + "P2W", + "P1DT12H", + "PT30M" + ] + }, "ordinalVersion": { "title": "Ordinal Version", "description": "An ordinal version is a dot-delimited, purely numeric identifier where each segment represents an ordered level in the hierarchy. The segments have no prescribed meaning beyond numeric ordering, allowing straightforward comparison and sorting.", diff --git a/schema/2.0/modules/cyclonedx-risk-2.0.schema.json b/schema/2.0/modules/cyclonedx-risk-2.0.schema.json index 206525cd2..7c05c2832 100644 --- a/schema/2.0/modules/cyclonedx-risk-2.0.schema.json +++ b/schema/2.0/modules/cyclonedx-risk-2.0.schema.json @@ -512,7 +512,7 @@ "description": "The expected number of events within the timeframe, for frequency-based methods such as the [FAIR](https://www.fairinstitute.org/) loss event frequency. Unlike a probability, a frequency may exceed 1." }, "timeframe": { - "type": "string", + "$ref": "cyclonedx-common-2.0.schema.json#/$defs/duration", "title": "Timeframe", "description": "The period over which the probability or frequency is assessed, expressed as an [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) duration, for example P1Y for one year." }, @@ -883,8 +883,7 @@ "description": "The number of affected users." }, "downtime": { - "type": "string", - "pattern": "^P(?!$)(\\d+Y)?(\\d+M)?(\\d+W)?(\\d+D)?(T(\\d+H)?(\\d+M)?(\\d+(\\.\\d+)?S)?)?$", + "$ref": "cyclonedx-common-2.0.schema.json#/$defs/duration", "description": "The expected downtime, as an [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) duration." }, "dataRecords": { @@ -892,8 +891,7 @@ "description": "The number of data records affected." }, "recovery": { - "type": "string", - "pattern": "^P(?!$)(\\d+Y)?(\\d+M)?(\\d+W)?(\\d+D)?(T(\\d+H)?(\\d+M)?(\\d+(\\.\\d+)?S)?)?$", + "$ref": "cyclonedx-common-2.0.schema.json#/$defs/duration", "description": "The recovery time, as an [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) duration." }, "financialLossRange": { @@ -1592,7 +1590,7 @@ "description": "The party accountable for setting and approving this appetite, such as a board or risk committee. May be an inline party object or a reference to a previously declared party." }, "horizon": { - "type": "string", + "$ref": "cyclonedx-common-2.0.schema.json#/$defs/duration", "description": "The time horizon over which this appetite applies, expressed as an [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) duration, for example P1Y for one year." }, "nextReview": { diff --git a/tools/src/test/resources/2.0/invalid-blueprint-review-frequency-weeks-2.0.json b/tools/src/test/resources/2.0/invalid-blueprint-review-frequency-weeks-2.0.json new file mode 100644 index 000000000..be1d3ac1a --- /dev/null +++ b/tools/src/test/resources/2.0/invalid-blueprint-review-frequency-weeks-2.0.json @@ -0,0 +1,21 @@ +{ + "specFormat": "CycloneDX", + "specVersion": "2.0", + "serialNumber": "urn:uuid:4c2a7d3f-9e5b-4f8c-8b21-7d6e5f4a3b2c", + "version": 1, + "blueprints": [ + { + "refId": "bp-review-frequency-weeks", + "name": "Weeks combined with months is not a valid ISO 8601 duration", + "modelTypes": [ + "data-flow" + ], + "metadata": { + "validityPeriod": { + "start": "2026-01-01T00:00:00Z", + "reviewFrequency": "P1M2W" + } + } + } + ] +} diff --git a/tools/src/test/resources/2.0/invalid-risk-likelihood-timeframe-2.0.json b/tools/src/test/resources/2.0/invalid-risk-likelihood-timeframe-2.0.json new file mode 100644 index 000000000..2ffa244a3 --- /dev/null +++ b/tools/src/test/resources/2.0/invalid-risk-likelihood-timeframe-2.0.json @@ -0,0 +1,18 @@ +{ + "specFormat": "CycloneDX", + "specVersion": "2.0", + "serialNumber": "urn:uuid:5d3b8e4a-1f6c-4a9d-9c32-8e7f6a5b4c3d", + "version": 1, + "risks": { + "risks": [ + { + "refId": "risk-timeframe", + "name": "Timeframe that is not a duration", + "statement": "The likelihood timeframe is free text instead of an ISO 8601 duration.", + "inherentRisk": { + "likelihood": { "level": "high", "timeframe": "one year" } + } + } + ] + } +} diff --git a/tools/src/test/resources/2.0/valid-blueprint-review-frequency-2.0.json b/tools/src/test/resources/2.0/valid-blueprint-review-frequency-2.0.json new file mode 100644 index 000000000..955787e87 --- /dev/null +++ b/tools/src/test/resources/2.0/valid-blueprint-review-frequency-2.0.json @@ -0,0 +1,21 @@ +{ + "specFormat": "CycloneDX", + "specVersion": "2.0", + "serialNumber": "urn:uuid:3b1f6c2e-8d4a-4e7b-9a10-6c5d4e3f2a1b", + "version": 1, + "blueprints": [ + { + "refId": "bp-review-frequency", + "name": "Blueprint with a review frequency that has a time part", + "modelTypes": [ + "data-flow" + ], + "metadata": { + "validityPeriod": { + "start": "2026-01-01T00:00:00Z", + "reviewFrequency": "P1DT12H" + } + } + } + ] +} From 12abd5aa3ade9cb27dd110f8ce13693bbf830ed9 Mon Sep 17 00:00:00 2001 From: Srinivas Chippagiri Date: Fri, 13 Nov 2026 10:04:15 -0800 Subject: [PATCH 2/3] fix(2.0): keep the duration pattern minimal and drop duplicate examples The pattern now only checks the leading P and a minimum length, and the full syntax is left to ISO 8601 itself. Signed-off-by: Srinivas Chippagiri --- schema/2.0/modules/cyclonedx-blueprint-2.0.schema.json | 3 +-- schema/2.0/modules/cyclonedx-common-2.0.schema.json | 6 ++++-- schema/2.0/modules/cyclonedx-risk-2.0.schema.json | 6 ++---- ...2.0.json => invalid-blueprint-review-frequency-2.0.json} | 6 +++--- 4 files changed, 10 insertions(+), 11 deletions(-) rename tools/src/test/resources/2.0/{invalid-blueprint-review-frequency-weeks-2.0.json => invalid-blueprint-review-frequency-2.0.json} (67%) diff --git a/schema/2.0/modules/cyclonedx-blueprint-2.0.schema.json b/schema/2.0/modules/cyclonedx-blueprint-2.0.schema.json index c93c2a48c..ec01b1d59 100644 --- a/schema/2.0/modules/cyclonedx-blueprint-2.0.schema.json +++ b/schema/2.0/modules/cyclonedx-blueprint-2.0.schema.json @@ -340,8 +340,7 @@ "reviewFrequency": { "$ref": "cyclonedx-common-2.0.schema.json#/$defs/duration", "title": "Review Frequency", - "description": "How often the blueprint is reviewed, as an [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) duration, for example `\"P3M\"` for quarterly.", - "examples": ["P1Y", "P3M", "P5W", "P23D"] + "description": "How often the blueprint is reviewed, as an [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) duration, for example `\"P3M\"` for quarterly." } } }, diff --git a/schema/2.0/modules/cyclonedx-common-2.0.schema.json b/schema/2.0/modules/cyclonedx-common-2.0.schema.json index a2bbb898a..c53176f31 100644 --- a/schema/2.0/modules/cyclonedx-common-2.0.schema.json +++ b/schema/2.0/modules/cyclonedx-common-2.0.schema.json @@ -682,8 +682,10 @@ "duration": { "type": "string", "title": "Duration", - "pattern": "^P(?!$)((\\d+Y)?(\\d+M)?(\\d+D)?(T(?=\\d)(\\d+H)?(\\d+M)?(\\d+(\\.\\d+)?S)?)?|\\d+W)$", - "description": "An [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) duration, such as 'P1Y', 'P3M', 'P1DT12H' or 'PT30M'. Weeks shall not be combined with other designators, so 'P2W' is valid but 'P1M2W' is not. Only the seconds may have a decimal fraction, e.g., 'PT0.5S'.", + "$comment": "The pattern only checks the leading designator on purpose. ISO 8601 already defines the full duration syntax, and repeating it as a complex regex here would duplicate the standard. Producers and consumers are expected to follow ISO 8601 in full.", + "pattern": "^P", + "minLength": 3, + "description": "[ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) duration", "examples": [ "P1Y", "P3M", diff --git a/schema/2.0/modules/cyclonedx-risk-2.0.schema.json b/schema/2.0/modules/cyclonedx-risk-2.0.schema.json index b30de7287..099c9a34b 100644 --- a/schema/2.0/modules/cyclonedx-risk-2.0.schema.json +++ b/schema/2.0/modules/cyclonedx-risk-2.0.schema.json @@ -514,8 +514,7 @@ "timeframe": { "$ref": "cyclonedx-common-2.0.schema.json#/$defs/duration", "title": "Timeframe", - "description": "The period over which the probability or frequency is assessed, expressed as an [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) duration, for example `\"P1Y\"` for one year.", - "examples": ["P1Y", "P1M", "P23DT23H", "PT1M"] + "description": "The period over which the probability or frequency is assessed, expressed as an [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) duration, for example `\"P1Y\"` for one year." }, "range": { "$ref": "#/$defs/estimateRange", @@ -1601,8 +1600,7 @@ }, "horizon": { "$ref": "cyclonedx-common-2.0.schema.json#/$defs/duration", - "description": "The time horizon over which this appetite applies, expressed as an [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) duration, for example `\"P1Y\"` for one year.", - "examples": ["P1Y", "P1M", "P23DT23H", "PT1M"] + "description": "The time horizon over which this appetite applies, expressed as an [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) duration, for example `\"P1Y\"` for one year." }, "nextReview": { "type": "string", diff --git a/tools/src/test/resources/2.0/invalid-blueprint-review-frequency-weeks-2.0.json b/tools/src/test/resources/2.0/invalid-blueprint-review-frequency-2.0.json similarity index 67% rename from tools/src/test/resources/2.0/invalid-blueprint-review-frequency-weeks-2.0.json rename to tools/src/test/resources/2.0/invalid-blueprint-review-frequency-2.0.json index be1d3ac1a..817c55863 100644 --- a/tools/src/test/resources/2.0/invalid-blueprint-review-frequency-weeks-2.0.json +++ b/tools/src/test/resources/2.0/invalid-blueprint-review-frequency-2.0.json @@ -5,15 +5,15 @@ "version": 1, "blueprints": [ { - "refId": "bp-review-frequency-weeks", - "name": "Weeks combined with months is not a valid ISO 8601 duration", + "refId": "bp-review-frequency-bare", + "name": "A bare designator is not a duration", "modelTypes": [ "data-flow" ], "metadata": { "validityPeriod": { "start": "2026-01-01T00:00:00Z", - "reviewFrequency": "P1M2W" + "reviewFrequency": "P" } } } From 12b5fdf4b2c79513b45acddee8fd4ba78d589dd1 Mon Sep 17 00:00:00 2001 From: Srinivas Chippagiri Date: Fri, 13 Nov 2026 10:05:30 -0800 Subject: [PATCH 3/3] fix(2.0): end the duration description with a full stop Signed-off-by: Srinivas Chippagiri --- schema/2.0/modules/cyclonedx-common-2.0.schema.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/schema/2.0/modules/cyclonedx-common-2.0.schema.json b/schema/2.0/modules/cyclonedx-common-2.0.schema.json index c53176f31..7c4ae381f 100644 --- a/schema/2.0/modules/cyclonedx-common-2.0.schema.json +++ b/schema/2.0/modules/cyclonedx-common-2.0.schema.json @@ -685,7 +685,7 @@ "$comment": "The pattern only checks the leading designator on purpose. ISO 8601 already defines the full duration syntax, and repeating it as a complex regex here would duplicate the standard. Producers and consumers are expected to follow ISO 8601 in full.", "pattern": "^P", "minLength": 3, - "description": "[ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) duration", + "description": "[ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) duration.", "examples": [ "P1Y", "P3M",