SWHID Verification Tool
A verification framework designed to map Package URLs (PURLs) to verified Software Heritage Identifiers (SWHIDs). This tool ensures cryptographic and structural provenance by establishing a verifiable link between software distributions and their canonical source code archived in the Software Heritage (SWH) ecosystem.
The Semantic Gap
In modern software development, we interact with dependencies using package-level identifiers (e.g., lodash@4.17.21 or requests@2.31.0). However, these packages are mutable and vulnerable to supply chain tampering.
To guarantee reproducibility and security, we need cryptographic, content-addressed identifiers like Software Heritage Identifiers (SWHIDs). Currently, there is a semantic gap between the package managers and the archive. This tool bridges that gap by automatically resolving package releases to verified SWHIDs across 6 major registries: PyPI, npm, Cargo, Go Modules, Maven Central, and NuGet.
📊 Showcase Dataset
We have generated a verified showcase dataset containing 25 of the most popular packages across all 5 ecosystems. The resulting SPDX 3.0 JSON-LD manifest is available at dataset/showcase_manifest.jsonld.
Verification Statistics
| Metric | Count | Percentage |
|---|---|---|
| Total Packages | 25 | 100% |
| Inferred (Medium Confidence) | 18 | 72.0% |
| Verified (High Confidence) | 1 | 4.0% |
| Partial (Low Confidence) | 1 | 4.0% |
| Errors/Failed | 5 | 20.0% |
Note: The "Inferred" status indicates that the repository was successfully matched and verified in the Software Heritage archive, but the specific version tag was not found in the latest snapshot. Running the tool with a Software Heritage API token resolves rate-limiting errors (HTTP 429) encountered during "Save Code Now" triggers.
Key Features
- Multi-Ecosystem Support: Specialized verification strategies for PyPI, npm, Cargo, Go Modules, Maven Central, and NuGet.
- High-Confidence Provenance:
- PyPI: Extraction of commit SHAs from Sigstore/PEP 740 attestations via Fulcio certificates.
- Cargo: Deterministic normalization and restoration of original project state for byte-for-byte matching.
- Maven: SCM metadata resolution and verification of cleaned source artifacts.
- OSV.dev Vulnerability Mapping: Content-based vulnerability scanning. Maps resolved cryptographic commit SHAs (
swh:1:rev:...) to known vulnerabilities in the OSV.dev database, eliminating false-negatives from package renaming/forks. - CI/CD Gatekeeping Policy Engine: Define compliance rules in
swhid-policy.toml(e.g. minimum confidence levels, fail-on-vulnerabilities, fail-on-mismatch, allowlists) to automatically break builds in CI/CD pipelines. - SPDX 3.0 Compliance: Generation of RDF-compatible JSON-LD manifests using official SPDX models.
- Automated Archival Integration: Proactive use of the Software Heritage "Save Code Now" API.
- Installation Verification: Local filesystem scanner to audit installed package directories and files recursively against verified SWHID ground truth.
Installation
Prerequisites
- Python 3.9+
- [Optional] A Software Heritage API Token for higher rate limits.
Setup
git clone https://github.com/OdysseasKalaitsidis/SWHID_POC
cd SWHID_POC
python -m venv venv
source venv/bin/activate # Use .\venv\Scripts\activate on Windows
pip install -r requirements.txt
Configuration
The tool can be configured via environment variables or a .env file:
| Variable | Description | Default |
|---|---|---|
SWH_TOKEN |
Software Heritage API Authentication Token | None |
CACHE_DIR |
Directory for caching resolution results | ./cache |
LOG_LEVEL |
Logging verbosity (DEBUG, INFO, ERROR) | INFO |
Usage
Quick Start
Map a single PURL to a verified SWHID immediately:
python -m swhid_tool.cli swhid-map pkg:pypi/six@1.17.0
Batch Processing
Generate an SPDX 3.0 dataset for multiple PURLs:
python -m swhid_tool.cli batch-process input_purls.txt output_report.jsonld
Integrity Auditing
Verify a local directory against a verified manifest:
python -m swhid_tool.cli verify-path /path/to/installed/library manifest.jsonld
REST API (Experimental)
Deploy as a service using FastAPI:
python -m uvicorn swhid_tool.api:app --host 0.0.0.0 --port 8000
Architecture
The system utilizes a strategy-based pattern to decouple ecosystem-specific logic from the core resolution engine.
graph TD
CLI[CLI / API] --> Manager[SWHID Manager]
Manager --> PURL[PURL Parser]
Manager --> StrategyRouter{Strategy Router}
StrategyRouter --> PyPI[PyPI Strategy]
StrategyRouter --> Cargo[Cargo Strategy]
StrategyRouter --> Maven[Maven Strategy]
PyPI --> SWH[SWH API / Archive]
Cargo --> SWH
Maven --> SWH
Manager --> Exporter[SPDX 3.0 Exporter]
Exporter --> JSONLD[JSON-LD Manifest]
Validation and Standards
Verification findings are exported as SPDX 3.0 documents. Compliance with RDF standards is ensured through SHACL shape validation using the integrated test_validation.py suite.
Documentation
Detailed guides for different stakeholders:
- User Guide: CLI reference, API specifications, and troubleshooting.
- Developer Guide: Extending the tool to new ecosystems and core internals.
- Maintainer Guide: Best practices for enabling high-confidence verifiability.
Contributing
Contributions are welcome! Please see the Developer Guide for setup instructions and coding standards.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
This project was independently developed, inspired by a GSoC proposal for Software Heritage. The SWHID standard (ISO/IEC 18670:2025) and the Software Heritage archive are projects of Inria.
Metadata
Release files for swhid-verification-tool 0.1.16
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| swhid_verification_tool-0.1.16.tar.gz | 44.2 kB | With provenance | Details for swhid_verification_tool-0.1.16.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| swhid_verification_tool-0.1.16-py3-none-any.whl | Python 3 | none | any | Details for swhid_verification_tool-0.1.16-py3-none-any.whl |
Total release size: 88.7 kB
Release files / swhid_verification_tool-0.1.16.tar.gz
| Download URL | swhid_verification_tool-0.1.16.tar.gz |
|---|---|
| Size | 44.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
00e7a3dac186b1edc3f6392a5a56129f9c8ff4edfd8a88a0eb053b244a110cc1
|
|
BLAKE2b-256 checksum How to use checksums |
48a240266fa63d2d96e804a8491830cd3b1779eba114af94ae7cc1d6084f6c1a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 11, 2026.
Transparency logRelease files / swhid_verification_tool-0.1.16-py3-none-any.whl
| Download URL | swhid_verification_tool-0.1.16-py3-none-any.whl |
|---|---|
| Size | 44.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b6abd7aeccf0a486c9787ff668a9f200a9549c8bbc7ab850cbae9b86a541038a
|
|
BLAKE2b-256 checksum How to use checksums |
385b96114b6a71c50013f0e145832b7a2d9710fda235632d55a40fa2b55ed3ec
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 11, 2026.
Transparency logSecurity for swhid-verification-tool 0.1.16
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for swhid_verification_tool-0.1.16.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 11, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.