Skip to main content

purl-license-checker

Retrieve missing licenses for purl documented dependencies.

CodeQL CI Downloads Supported Versions Contributors

This cli utility takes one or more purl formatted urls from stdin and will try to find the license attached to each of them, by querying various package managers databases.

This is particularly useful to fill GitHub's Dependabot gap of missing 90% of licenses when working at scale with ghas-cli for instance.

Supported package managers:

Installation

Builds are available in the Releases tab and on Pypi

  • Pypi:
pip install purl-license-checker
  • Manually:
python -m pip install /full/path/to/purl-license-checker-xxx.whl

# e.g: python3 -m pip install Downloads/purl-license-checker-0.5.0-none-any.whl

Usage

To show the help message for each command, run purl-license-checker -h:

Usage: purl-license-checker [OPTIONS] COMMAND [ARGS]...

  Retrieve licenses for purl documented dependencies.

  Get help: `@jboursier-mwb` on GitHub

Options:
  --help  Show this message and exit.

Commands:
  get_license
  load_file
  merge_csv

Get a license

get_license PURL GITHUB_TOKEN

e.g:

get_license pip:ghas-cli gh-123456789qwerty

Find licenses for a csv-list of purl dependencies

load_file PATH GITHUB_TOKEN

e.g:

With a PATH csv file formatted as follow:

repo_name, purl, version, license

Where missing licenses are set to Unknown, for instance:

ghas-cli, ghas-cli, com.github.Malwarebytes/ghas-cli,, MIT
ghas-cli, pip:charset-normalizer,3.3.2, MIT
ghas-cli, pip:colorama,0.4.6, BSD-2-Clause AND BSD-3-Clause
ghas-cli, pip:click,8.1.7, BSD-2-Clause AND BSD-3-Clause
ghas-cli, pip:python-magic,0.4.27, MIT
ghas-cli, pip:urllib3,2.2.3, MIT
ghas-cli, pip:requests,2.32.3, Apache-2.0
ghas-cli, pip:configparser,7.1.0, MIT
ghas-cli, pip:certifi,2024.8.30, MPL-2.0
ghas-cli, pip:idna,3.10, BSD-2-Clause AND BSD-3-Clause
ghas-cli, actions:actions/checkout,4.*.*, Unknown
ghas-cli, actions:github/codeql-action/analyze,3.*.*, Unknown
ghas-cli, actions:github/codeql-action/init,3.*.*, Unknown
ghas-cli, actions:actions/dependency-review-action,4.*.*, Unknown

load_file will do its best to find the licenses for all Unknown license fields and will output its results in output.csv.

The output format is as follow:

purl, license

For instance:

npm:unicode-match-property-ecmascript, MIT
npm:unicode-match-property-value-ecmascript, MIT
npm:unicode-property-aliases-ecmascript, MIT
npm:universalify, MIT
npm:unpipe, MIT
npm:use-sync-external-store, MIT
npm:util-deprecate, MIT
npm:utils-merge, MIT

Fill an existing partial csv list of purl licenses

merge_csv LICENSES_INPUT_PATH DEPENDENCIES_OUTPUT_PATH GITHUB_TOKEN

Allows to fill the unknown dependencies in DEPENDENCIES_OUTPUT_PATH formatted as repo_name, purl, version, license from LICENSES_INPUT_PATH containing only purl, license. Particularly useful with a workflow based on ghas-cli.

Development

Build

Install uv first, then:

make dev

Bump the version number

  • Bump the version number: uv version --minor
  • Update the __version__ field in src/cli.py accordingly.

Publish a new version

Requires syft to be installed to generate the sbom.

  1. Bump the version number as described above
  2. make release to build the packages
  3. git commit -a -S Bump to version 1.1.2 and git tag -s v1.1.2 -m "1.1.2"
  4. Upload dist/*, checksums.sha512 and checksums.sha512.asc to a new release in GitHub.

Miscellaneous

This repository is provided as-is and isn't bound to Malwarebytes' SLA.

Metadata

Release files for purl-license-checker 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for purl-license-checker 0.3.0
File Size Uploaded
purl_license_checker-0.3.0.tar.gz 5.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for purl-license-checker 0.3.0
File Interpreter ABI Platform
purl_license_checker-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 12.6 kB

Release files / purl_license_checker-0.3.0.tar.gz

Download URL purl_license_checker-0.3.0.tar.gz
Size 5.6 kB
Tags Source
SHA-256 checksum
How to use checksums
8f65dc6242786825f6afaa14e787a188515cdadb3a4ad716d8a2acbb89e632b4
BLAKE2b-256 checksum
How to use checksums
a58e010ad6f3c6c48e2a9c8173653614e46e6e5be9ac638d957bfa52c70b5322
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.7.19

Release files / purl_license_checker-0.3.0-py3-none-any.whl

Download URL purl_license_checker-0.3.0-py3-none-any.whl
Size 7.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
239461319fe5a5e6e84c5547f868dddfe3c437d971bbad2bb085b0a6f8193428
BLAKE2b-256 checksum
How to use checksums
bac224a665723d3933fb76400609d028bd3f1fc4a974cb49f818b69e0b90ae59
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.7.19

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files

0.2.0

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page