Skip to content

Commit 6bc20d1

Browse files
authored
Upgrade the SPDX schema to v2.3.1 #1130 (#1139)
Signed-off-by: tdruez <tdruez@nexb.com>
1 parent 6ca4083 commit 6bc20d1

File tree

6 files changed

+65
-14
lines changed

6 files changed

+65
-14
lines changed

CHANGELOG.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ v34.2.0 (unreleased)
1010
- Add support for CycloneDX XML inputs.
1111
https://github.com/nexB/scancode.io/issues/1136
1212

13+
- Upgrade the SPDX schema to v2.3.1
14+
https://github.com/nexB/scancode.io/issues/1130
15+
1316
v34.1.0 (2024-03-27)
1417
--------------------
1518

scanpipe/pipes/schemas/spdx-schema-2.3.json

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
{
2-
"$schema" : "http://json-schema.org/draft-07/schema#",
2+
"$schema" : "https://json-schema.org/draft/2019-09/schema#",
33
"$id" : "http://spdx.org/rdf/terms/2.3",
44
"title" : "SPDX 2.3",
55
"type" : "object",
66
"properties" : {
7+
"$schema": {
8+
"type": "string",
9+
"description": "Reference the SPDX 2.3 JSON schema."
10+
},
711
"SPDXID" : {
812
"type" : "string",
913
"description" : "Uniquely identify any element in an SPDX document which may be referenced by other elements."
@@ -187,6 +191,7 @@
187191
},
188192
"revieweds" : {
189193
"description" : "Reviewed",
194+
"deprecated": true,
190195
"type" : "array",
191196
"items" : {
192197
"type" : "object",
@@ -217,7 +222,9 @@
217222
"description" : "The URI provides an unambiguous mechanism for other SPDX documents to reference SPDX elements within this SPDX document."
218223
},
219224
"documentDescribes" : {
220-
"description" : "Packages, files and/or Snippets described by this SPDX document",
225+
"description" : "DEPRECATED: use relationships instead of this field. Packages, files and/or Snippets described by this SPDX document",
226+
"deprecated": true,
227+
"$comment": "This field has been deprecated as it is a duplicate of using the SPDXRef-DOCUMENT DESCRIBES relationship",
221228
"type" : "array",
222229
"items" : {
223230
"type" : "string",
@@ -322,14 +329,14 @@
322329
"referenceCategory" : {
323330
"description" : "Category for the external reference",
324331
"type" : "string",
325-
"enum" : [ "OTHER", "PERSISTENT-ID", "SECURITY", "PACKAGE-MANAGER" ]
332+
"enum" : [ "OTHER", "PERSISTENT-ID", "PERSISTENT_ID", "SECURITY", "PACKAGE-MANAGER", "PACKAGE_MANAGER" ]
326333
},
327334
"referenceLocator" : {
328335
"description" : "The unique string with no spaces necessary to access the package-specific information, metadata, or content within the target location. The format of the locator is subject to constraints defined by the <type>.",
329336
"type" : "string"
330337
},
331338
"referenceType" : {
332-
"description" : "Type of the external reference. These are definined in an appendix in the SPDX specification.",
339+
"description" : "Type of the external reference. These are defined in an appendix in the SPDX specification.",
333340
"type" : "string"
334341
}
335342
},
@@ -343,7 +350,9 @@
343350
"type" : "boolean"
344351
},
345352
"hasFiles" : {
346-
"description" : "Indicates that a particular file belongs to a package.",
353+
"description" : "DEPRECATED: use relationships instead of this field. Indicates that a particular file belongs to a package.",
354+
"deprecated": true,
355+
"$comment": "This field has been deprecated as it is a duplicate of using CONTAINS relationships from a package to files",
347356
"type" : "array",
348357
"items" : {
349358
"description" : "SPDX ID for File. Indicates that a particular file belongs to a package.",
@@ -366,10 +375,10 @@
366375
"type" : "string"
367376
},
368377
"licenseInfoFromFiles" : {
369-
"description" : "The licensing information that was discovered directly within the package. There will be an instance of this property for each distinct value of alllicenseInfoInFile properties of all files contained in the package.\n\nIf the licenseInfoFromFiles field is not present for a package and filesAnalyzed property for that same pacakge is true or omitted, it implies an equivalent meaning to NOASSERTION.",
378+
"description" : "The licensing information that was discovered directly within the package. There will be an instance of this property for each distinct value of alllicenseInfoInFile properties of all files contained in the package.\n\nIf the licenseInfoFromFiles field is not present for a package and filesAnalyzed property for that same package is true or omitted, it implies an equivalent meaning to NOASSERTION.",
370379
"type" : "array",
371380
"items" : {
372-
"description" : "License expression for licenseInfoFromFiles. See SPDX Annex D for the license expression syntax. The licensing information that was discovered directly within the package. There will be an instance of this property for each distinct value of alllicenseInfoInFile properties of all files contained in the package.\n\nIf the licenseInfoFromFiles field is not present for a package and filesAnalyzed property for that same pacakge is true or omitted, it implies an equivalent meaning to NOASSERTION.",
381+
"description" : "License expression for licenseInfoFromFiles. See SPDX Annex D for the license expression syntax. The licensing information that was discovered directly within the package. There will be an instance of this property for each distinct value of alllicenseInfoInFile properties of all files contained in the package.\n\nIf the licenseInfoFromFiles field is not present for a package and filesAnalyzed property for that same package is true or omitted, it implies an equivalent meaning to NOASSERTION.",
373382
"type" : "string"
374383
}
375384
},
@@ -531,6 +540,7 @@
531540
},
532541
"fileDependencies" : {
533542
"description" : "This field is deprecated since SPDX 2.0 in favor of using Section 7 which provides more granularity about relationships.",
543+
"deprecated": true,
534544
"type" : "array",
535545
"items" : {
536546
"description" : "SPDX ID for File. This field is deprecated since SPDX 2.0 in favor of using Section 7 which provides more granularity about relationships.",
@@ -735,6 +745,6 @@
735745
}
736746
}
737747
},
738-
"required" : [ "SPDXID", "creationInfo", "dataLicense", "name", "spdxVersion" ],
748+
"required" : [ "SPDXID", "creationInfo", "dataLicense", "name", "spdxVersion", "documentNamespace" ],
739749
"additionalProperties" : false
740-
}
750+
}

scanpipe/pipes/schemas/spdx-schema-2.3.json.ABOUT

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
about_resource: spdx-schema-2.3.json
22
name: spdx-spec
33
version: 2.3
4-
download_url: https://github.com/spdx/spdx-spec/archive/refs/tags/v2.3.zip
4+
download_url: https://github.com/spdx/spdx-spec/raw/development/v2.3.1/schemas/spdx-schema.json
55
description: The Software Package Data Exchange® (SPDX®) specification is a standard format
66
for communicating the components, licenses and copyrights associated with software packages.
77
homepage_url: https://spdx.org
8-
package_url: pkg:github/spdx/spdx-spec@2.3?version_prefix=v#schemas/spdx-schema.json
8+
package_url: pkg:github/spdx/spdx-spec@2.3.1?version_prefix=v#schemas/spdx-schema.json
99
license_expression: cc-by-3.0
1010
copyright: Copyright (c) SPDX project contributors
1111
attribute: yes
1212
track_changes: yes
13-
checksum_md5: e5b8b72262e342b63cc3dc888f191dbe
14-
checksum_sha1: 186f20921d05d6bb8f2fe9b4c63a795abffa2a98
1513
licenses:
1614
- key: cc-by-3.0
1715
name: Creative Commons Attribution License 3.0

scanpipe/pipes/spdx.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
SPDX_SCHEMA_NAME = "spdx-schema-2.3.json"
3535
SPDX_SCHEMA_PATH = Path(__file__).parent / "schemas" / SPDX_SCHEMA_NAME
3636
SPDX_SCHEMA_URL = (
37-
"https://raw.githubusercontent.com/spdx/spdx-spec/v2.3/schemas/spdx-schema.json"
37+
"https://github.com/spdx/spdx-spec/raw/development/v2.3.1/schemas/spdx-schema.json"
3838
)
3939

4040
"""
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"spdxVersion": "SPDX-2.3",
3+
"dataLicense": "CC0-1.0",
4+
"SPDXID": "SPDXRef-DOCUMENT",
5+
"name": "scancodeio_asgiref",
6+
"documentNamespace": "https://scancode.io/spdxdocs/8d3058f3-ec1f-487d-8c5f-b2d3b26cda3e",
7+
"creationInfo": {
8+
"created": "2000-01-01T01:02:03Z",
9+
"creators": [
10+
"Tool: ScanCode.io-31.0.0"
11+
],
12+
"licenseListVersion": "3.20"
13+
},
14+
"packages": [
15+
{
16+
"name": "asgiref",
17+
"SPDXID": "SPDXRef-scancodeio-discoveredpackage-b6ef7c90-e3d4-4008-8b67-63f086cea2da",
18+
"downloadLocation": "NOASSERTION",
19+
"licenseConcluded": "BSD-3-Clause",
20+
"copyrightText": "NOASSERTION",
21+
"filesAnalyzed": false,
22+
"versionInfo": "3.3.0",
23+
"licenseDeclared": "BSD-3-Clause",
24+
"externalRefs": [
25+
{
26+
"referenceCategory": "PACKAGE_MANAGER",
27+
"referenceType": "purl",
28+
"referenceLocator": "pkg:pypi/asgiref@3.3.0"
29+
}
30+
]
31+
}
32+
]
33+
}

scanpipe/tests/pipes/test_spdx.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,15 @@
2020
# ScanCode.io is a free software code scanning tool from nexB Inc. and others.
2121
# Visit https://github.com/nexB/scancode.io for support and download.
2222

23+
from pathlib import Path
2324
from unittest import TestCase
2425

2526
from scanpipe.pipes import spdx
2627

2728

2829
class ScanPipeSPDXPipesTest(TestCase):
30+
data_location = Path(__file__).parent.parent / "data"
31+
2932
def setUp(self):
3033
self.schema = spdx.SPDX_SCHEMA_PATH.read_text()
3134

@@ -373,5 +376,9 @@ def test_spdx_validate_document(self):
373376
document = spdx.Document(**self.document_data)
374377
spdx.validate_document(document, self.schema)
375378

379+
# Testing support for "PACKAGE_MANAGER" in place of "PACKAGE-MANAGER"
380+
document_location = self.data_location / "spdx" / "example-2.3.1.json"
381+
spdx.validate_document(document_location.read_text(), self.schema)
382+
376383
with self.assertRaises(Exception):
377384
spdx.validate_document({}, self.schema)

0 commit comments

Comments
 (0)