Skip to content

Commit

Permalink
refactor: centralize version and version-range
Browse files Browse the repository at this point in the history
Signed-off-by: Jan Kowalleck <jan.kowalleck@gmail.com>
  • Loading branch information
jkowalleck committed Oct 19, 2023
1 parent 5d8c05b commit 92ae29e
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 17 deletions.
42 changes: 30 additions & 12 deletions schema/bom-1.6.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@
"description": "The name of the tool"
},
"version": {
"type": "string",
"$ref": "#/definitions/version",
"title": "Tool Version",
"description": "The version of the tool"
},
Expand Down Expand Up @@ -457,10 +457,9 @@
"examples": ["tomcat-catalina"]
},
"version": {
"type": "string",
"$ref": "#/definitions/version",
"title": "Component Version",
"description": "The component version. The version should ideally comply with semantic versioning but is not enforced.",
"examples": ["9.0.14"]
"description": "The component version. The version should ideally comply with semantic versioning but is not enforced."
},
"description": {
"type": "string",
Expand Down Expand Up @@ -1277,10 +1276,9 @@
"examples": ["ticker-service"]
},
"version": {
"type": "string",
"$ref": "#/definitions/version",
"title": "Service Version",
"description": "The service version.",
"examples": ["1.0.0"]
"description": "The service version."
},
"description": {
"type": "string",
Expand Down Expand Up @@ -2285,7 +2283,7 @@
},
"range": {
"description": "A version range specified in Package URL Version Range syntax (vers) which is defined at https://github.com/package-url/purl-spec/VERSION-RANGE-SPEC.rst",
"$ref": "#/definitions/range"
"$ref": "#/definitions/versionRange"
},
"status": {
"description": "The vulnerability status for the version or range of versions.",
Expand Down Expand Up @@ -2320,16 +2318,36 @@
]
},
"version": {
"description": "A single version of a component or service.",
"description": "A single disjunctive version identifier, for a component or service.",
"type": "string",
"minLength": 1,
"maxLength": 1024
"maxLength": 1024,
"examples": [
"9.0.14",
"v1.33.7",
"7.0.0-M1",
"2.0pre1",
"1.0.0-beta1",
"0.8.15"
]
},
"range": {
"versionRange": {
"description": "A version range specified in Package URL Version Range syntax (vers) which is defined at https://github.com/package-url/purl-spec/VERSION-RANGE-SPEC.rst",
"type": "string",
"minLength": 1,
"maxLength": 1024
"maxLength": 1024,
"examples": [
"9.0.14",
"1.2.3|>=2.0.0|<5.0.0",
"0.0.0|0.0.1|0.0.2|0.0.3|1.0|2.0pre1",
">=1.0.0-beta1|<=1.7.5|>=7.0.0-M1|<=7.0.7|>=7.1.0|<=7.1.2|>=8.0.0-M1|<=8.0.1",
">=2.2.0|!= 2.2.1|<2.3.0"
]
},
"range": {
"deprecated": true,
"description": "Deprecated definition. use definition `versionRange` instead.",
"allOf": [{"$ref": "#/definitions/versionRange"}]
},
"annotations": {
"type": "object",
Expand Down
47 changes: 42 additions & 5 deletions schema/bom-1.6.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,43 @@ limitations under the License.
<xs:restriction base="bom:refType"/>
</xs:simpleType>

<xs:simpleType name="versionType">
<xs:annotation>
<xs:documentation xml:lang="en"><![CDATA[
A single disjunctive version identifier, for a component or service.
Example values:
- "9.0.14"
- "v1.33.7"
- "7.0.0-M1"
- "2.0pre1"
- "1.0.0-beta1"
- "0.8.15"
]]>
</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:normalizedString"/>
</xs:simpleType>
<xs:simpleType name="versionRangeType">
<xs:annotation>
<xs:documentation xml:lang="en"><![CDATA[
A version range specified in Package URL Version Range syntax (vers) which is defined at https://github.com/package-url/purl-spec/VERSION-RANGE-SPEC.rst
Example values:
- "9.0.14"
- "1.2.3|>=2.0.0|<5.0.0"
- "0.0.0|0.0.1|0.0.2|0.0.3|1.0|2.0pre1"
- ">=1.0.0-beta1|<=1.7.5|>=7.0.0-M1|<=7.0.7|>=7.1.0|<=7.1.2|>=8.0.0-M1|<=8.0.1"
- ">=2.2.0|!= 2.2.1|<2.3.0"
]]>
</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:normalizedString">
<xs:minLength value="1"/>
<xs:maxLength value="1024"/>
</xs:restriction>
</xs:simpleType>

<xs:simpleType name="bomLinkDocumentType">
<xs:annotation>
<xs:documentation xml:lang="en">
Expand Down Expand Up @@ -338,7 +375,7 @@ limitations under the License.
<xs:documentation>The name of the tool</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="version" minOccurs="0" maxOccurs="1" type="xs:normalizedString">
<xs:element name="version" minOccurs="0" maxOccurs="1" type="bom:versionType">
<xs:annotation>
<xs:documentation>The version of the tool</xs:documentation>
</xs:annotation>
Expand Down Expand Up @@ -463,7 +500,7 @@ limitations under the License.
of the component. Examples: commons-lang3 and jquery</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="version" type="xs:normalizedString" minOccurs="0" maxOccurs="1">
<xs:element name="version" type="bom:versionType" minOccurs="0" maxOccurs="1">
<xs:annotation>
<xs:documentation>The component version. The version should ideally comply with semantic versioning
but is not enforced.</xs:documentation>
Expand Down Expand Up @@ -1851,7 +1888,7 @@ limitations under the License.
of the service.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="version" type="xs:normalizedString" minOccurs="0" maxOccurs="1">
<xs:element name="version" type="bom:versionType" minOccurs="0" maxOccurs="1">
<xs:annotation>
<xs:documentation>The service version.</xs:documentation>
</xs:annotation>
Expand Down Expand Up @@ -3637,12 +3674,12 @@ limitations under the License.
<xs:complexType>
<xs:sequence minOccurs="0" maxOccurs="1">
<xs:choice>
<xs:element name="version" type="xs:normalizedString" minOccurs="1" maxOccurs="1">
<xs:element name="version" type="bom:versionType" minOccurs="1" maxOccurs="1">
<xs:annotation>
<xs:documentation>A single version of a component or service.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="range" type="xs:normalizedString" minOccurs="1" maxOccurs="1">
<xs:element name="range" type="bom:versionRangeType" minOccurs="1" maxOccurs="1">
<xs:annotation>
<xs:documentation>A version range specified in Package URL Version Range syntax (vers) which is defined at https://github.com/package-url/purl-spec/VERSION-RANGE-SPEC.rst</xs:documentation>
</xs:annotation>
Expand Down

0 comments on commit 92ae29e

Please sign in to comment.