Skip to main content

SPDX 3 Validation Tool

Validates SPDX 3 documents

While standalone tools like pyshacl and check-jsonschema can be used to validate SPDX 3 documents, there are a few context-aware checks that can be useful. This includes:

  1. Ignored SHACL errors for missing spdxIds if they are defined in an ExternalMap
  2. Validation that any spdxId defined in an ExternalMap are not present in the document
  3. SHACL Validation of merged documents (in this way, if you reference an spdxId from an ExternalMap and then pass the document that provides that spdxId, the type can be validated)
  4. (Hopefully) More useful JSON schema error output

Installation

spdx3-validate can be installed using pip:

python3 -m pip install spdx3-validate

Using as a library

spdx3-validate can also be used programmatically. validate() takes a single source or an iterable of sources (a path or a URL) and returns a ValidationResult:

import spdx3_validate

result = spdx3_validate.validate("doc.spdx3.json")
if not result:
    print(result)  # prints the errors, one per line

# Or inspect the individual findings:
for error in result.errors:
    print(error)
  • The SPDX version is detected from each document's @context; pass version="X.Y" to force one.
  • Set check_merged=True to also validate the merged graph of several documents together.
  • A document that cannot be loaded (missing @context, unknown version, incompatible versions) raises spdx3_validate.SpdxValidateError.

Developing

Developing on spdx3-validate is best done using a virtual environment. You can configure one and install spdx3-validate in editable mode with all necessary development dependencies by running:

python3 -m venv .venv
. .venv/bin/activate
pip install -e ".[dev]"

TODO

  • Option to automatically download dependencies based on locationHint
  • Offline validation?
  • Cache downloaded context

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

spdx3_validate-0.0.7.tar.gz (13.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

spdx3_validate-0.0.7-py3-none-any.whl (12.2 kB view details)

Uploaded Python 3

File details

Details for the file spdx3_validate-0.0.7.tar.gz.

File metadata

  • Download URL: spdx3_validate-0.0.7.tar.gz
  • Upload date:
  • Size: 13.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for spdx3_validate-0.0.7.tar.gz
Algorithm Hash digest
SHA256 167d4f18ecd643af80290d8b3edde16e9142f528a013b7e45be712e539b5b93a
MD5 98c3d84b8ee239e1665f7b12cd7c9d55
BLAKE2b-256 5297ddfbdf43953f7f284ce4b1b495b86091e1c30253fe5218297d934070e4de

See more details on using hashes here.

Provenance

The following attestation bundles were made for spdx3_validate-0.0.7.tar.gz:

Publisher: publish.yaml on JPEWdev/spdx3-validate

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file spdx3_validate-0.0.7-py3-none-any.whl.

File metadata

  • Download URL: spdx3_validate-0.0.7-py3-none-any.whl
  • Upload date:
  • Size: 12.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for spdx3_validate-0.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 722759285636c8e73e6485d5789128e7af1911c0586d7a1bd07c42f8644d091f
MD5 81b06c393d756d9c7e3a545006a6fafc
BLAKE2b-256 3d5c8d091c82061bd96d5bcc3b47edb98810ee9c6adde95910a7f6cb86a233b0

See more details on using hashes here.

Provenance

The following attestation bundles were made for spdx3_validate-0.0.7-py3-none-any.whl:

Publisher: publish.yaml on JPEWdev/spdx3-validate

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.0.7 This release

2 files

0.0.5

2 files

0.0.4

2 files

0.0.2

2 files

0.0.1

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page