Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: centralize version and version-range #322

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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": {
Copy link
Member Author

@jkowalleck jkowalleck Oct 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the name was too broad. Therefore, it needed to be renamed to version-range

BUT range was an existing definition, which may have been used/referenced in JSON schemas downstream, by organizations that build super/subsets of our schema. (like @siemens did this in the past.)
Therefore, we cannot simply remove/rename it.

SO it stayed as is, but is marked as deprecated and "inherits" from the new definition.

"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