Query SPDX 3 data files
Project description
spdx3query
Command line tool for querying SPDX 3 files
Installation
spdx3query can be installed using pip:
python3 -m pip install spdx3query
Usage
spdx3query takes one or mode SPDX 3 JSON files as input using the -i option
and then a subcommand to query information about it. For example, this command
will list all Build objects found in my-sdpx.spdx.json:
spdx3query -i my-spdx.spdx.json find --type build_Build
There are many commands that spdx3query supports. For a list of commands, see
spdx3query --help. Each command also implements a --help which can provide
additional information about what it does, for example spdx3query find --help
Interactive mode
In addition to the top level subcommands of sdpx3query, there is also an
interactive mode where commands can be run. This can be useful for
interactively exploring SPDX 3 files, particularly if they are very large as
the dataset only needs to be loaded once. To enter interactive mode, the
interactive subcommand is used, for example:
spdx3query -i my-spdx.spdx.json interactive
From the prompt, any query subcommand can be run in the same way as if it had been specified on the command line, for example:
> find --type build_Build
Object Mnemonic Handles
Objects in SPDX 3 are often assigned IRIs as identifiers (either in the @id
or spdxId property, depending on the object). These IRI names are often very
long and can be difficult to type in correctly when performing queries on a
data file. To aid in identifying objects, spdx3query assigns a mnemonic to
each device that can be used in place of the identifier. The mnemonic uses
words from the BIP 39 word list, and by default uses 3 terms. If you are
dealing with a large datafile, you can increase the number of terms using the
--handle-terms argument to spdx3query. The mnemonic handle is based on a
hash of the actual ID, and therefore is stable even when loading the same file
multiple times.
As an example, you can see the mnemonic handle for the following build object is "chest-acoustic-phone"
$ spdx3query -i bitbake.spdx.json find --type build_Build --show
Loaded 18 objects in 0.01s
Found 1 object(s):
build_Build - 'chest-acoustic-phone'
spdxId: 'http://spdx.org/spdxdoc/bitbake-addba517-4804-5ae3-87c2-0c3a1a5812ba/bitbake/2ae7c23f5bf50e79d5c97b3a3f2294bb'
This means that you can can use this mnemonic handle in place of the actual spdxId to reference this object, e.g.:
spdx3query -i bitbake.spdx.json show chest-acoustic-phone
For objects that do not have an ID, a mnemonic handle will also be assigned,
but it will have a LOCAL- prefix prepended to it. These handles are not
guaranteed to remain the same between different invocations of spdx3query.
For example:
$ spdx3query -i bitbake.spdx.json find --type CreationInfo
Loaded 18 objects in 0.01s
Found 1 object(s):
CreationInfo - 'LOCAL-stereo-window-riot'
Development
Development on spdx3query can be done by setting up a virtual environment and
installing it in editable mode:
python3 -m venv .venv
. .venv/bin/activate
pip install -e .[dev]
Tests can be run using pytest:
pytest -v
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file spdx3query-0.0.4.tar.gz.
File metadata
- Download URL: spdx3query-0.0.4.tar.gz
- Upload date:
- Size: 59.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5f1a1e3c6ddc823ac5138873aae3a85740abc836db6dfa695aba4aa05ddee8e7
|
|
| MD5 |
6962c67def88c2364445347ff28a2a9d
|
|
| BLAKE2b-256 |
b9f62e11bd4b9a6f248569439fa59dee3a602ae176c8187983a8fba4621ce3a2
|
Provenance
The following attestation bundles were made for spdx3query-0.0.4.tar.gz:
Publisher:
publish.yaml on JPEWdev/spdx3query
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
spdx3query-0.0.4.tar.gz -
Subject digest:
5f1a1e3c6ddc823ac5138873aae3a85740abc836db6dfa695aba4aa05ddee8e7 - Sigstore transparency entry: 151388839
- Sigstore integration time:
-
Permalink:
JPEWdev/spdx3query@87fd65283c1247d0b2f3d417fab64bf45c54c93f -
Branch / Tag:
refs/tags/v0.0.4 - Owner: https://github.com/JPEWdev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@87fd65283c1247d0b2f3d417fab64bf45c54c93f -
Trigger Event:
release
-
Statement type:
File details
Details for the file spdx3query-0.0.4-py3-none-any.whl.
File metadata
- Download URL: spdx3query-0.0.4-py3-none-any.whl
- Upload date:
- Size: 62.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6a605419fe843da6cc4dcec90e243cd5fe2c13b63b2c4e9d45dab91fd6f4cd20
|
|
| MD5 |
b0e2221284deddfcd0667efff8cf1c49
|
|
| BLAKE2b-256 |
748861e8470a885a2bf011c4f317f53db8e0f4c164ddb181c5096f43cc58cd83
|
Provenance
The following attestation bundles were made for spdx3query-0.0.4-py3-none-any.whl:
Publisher:
publish.yaml on JPEWdev/spdx3query
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
spdx3query-0.0.4-py3-none-any.whl -
Subject digest:
6a605419fe843da6cc4dcec90e243cd5fe2c13b63b2c4e9d45dab91fd6f4cd20 - Sigstore transparency entry: 151388842
- Sigstore integration time:
-
Permalink:
JPEWdev/spdx3query@87fd65283c1247d0b2f3d417fab64bf45c54c93f -
Branch / Tag:
refs/tags/v0.0.4 - Owner: https://github.com/JPEWdev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@87fd65283c1247d0b2f3d417fab64bf45c54c93f -
Trigger Event:
release
-
Statement type: