| check_purl.py |
check_purl.py — Validate github/gitlab Package URLs (PURLs) and check
whether the repo (and optional version/ref) actually exists.
Why not aboutcode-org/purldb-toolkit for this?
purldb-toolkit's `purlcli validate` command is a good general-purpose
purl validator, but its existence check ("check_existence") only
covers cargo, composer, deb, gem, golang, hex, maven, npm, nuget and
pypi (per its own source: purldb_toolkit/purlcli.py, validate_purl()).
`github` and `gitlab` are not in that list, so it falls back to
"check_existence_not_supported" for exactly the two types we care
about here. Syntax validation (via packageurl-python, which purldb-
toolkit also uses under the hood) works fine for these types — it's
only the existence check that's missing — so this script covers
that gap by querying the GitHub/GitLab APIs directly.
Requires:
pip install packageurl-python requests
Usage:
python check_purl.py pkg:github/psf/requests@v2.31.0
python check_purl.py pkg:gitlab/gitlab-org/gitlab@master
python check_purl.py --file purls.txt # one purl per line
python check_purl.py --github-token YOUR_GH_TOKEN pkg:github/psf/requests
Exit code is 0 only if every purl resolved to 'ok' or was skipped (non
github/gitlab type). Any 'not found', 'error' (couldn't verify — e.g.
rate limit or network issue), or 'invalid' (malformed syntax) result
causes a non-zero exit and is broken out in the summary printed at the end.
|
11930 |
- |