| Crates.io | uv-sbom |
| lib.rs | uv-sbom |
| version | 1.0.0 |
| created_at | 2026-01-04 09:21:17.64168+00 |
| updated_at | 2026-01-24 03:19:42.400434+00 |
| description | SBOM generation tool for uv projects - Generate CycloneDX SBOMs from uv.lock files |
| homepage | https://github.com/Taketo-Yoda/uv-sbom |
| repository | https://github.com/Taketo-Yoda/uv-sbom |
| max_upload_size | |
| id | 2021643 |
| size | 528,504 |
Generate SBOMs (Software Bill of Materials) for Python projects managed by uv.
uv.lock files to extract dependency informationThis tool generates SBOMs based on uv.lock file contents, which includes:
What's NOT included:
As of v7.2.1, the official cyclonedx-python library does not yet provide direct support for uv. When generating SBOMs for Python projects:
| Aspect | uv-sbom (this tool) | CycloneDX Official Tools |
|---|---|---|
| Data Source | uv.lock file |
.venv virtual environment |
| Scope | Production runtime dependencies only | Entire supply chain including build/dev tools |
| Package Count | Typically fewer (e.g., 16 packages) | Typically more (e.g., 38+ packages) |
| Use Case | Production security scanning | Comprehensive supply chain audit |
| Accuracy | Reflects locked dependencies | Reflects installed packages |
uv-sbom to focus on dependencies that will be deployed to productionThe focused approach of uv-sbom reduces noise in security vulnerability scanning by excluding build-time dependencies that don't ship with the final application.
Install from crates.io:
cargo install uv-sbom
Install the Python wrapper package:
uv tool install uv-sbom-bin
Or via pip:
pip install uv-sbom-bin
After installation, use the uv-sbom command:
uv-sbom --version
Note: The package name is uv-sbom-bin, but the installed command is uv-sbom.
Download pre-built binaries from GitHub Releases:
macOS (Apple Silicon):
curl -LO https://github.com/Taketo-Yoda/uv-sbom/releases/latest/download/uv-sbom-aarch64-apple-darwin.tar.gz
tar xzf uv-sbom-aarch64-apple-darwin.tar.gz
sudo mv uv-sbom /usr/local/bin/
macOS (Intel):
curl -LO https://github.com/Taketo-Yoda/uv-sbom/releases/latest/download/uv-sbom-x86_64-apple-darwin.tar.gz
tar xzf uv-sbom-x86_64-apple-darwin.tar.gz
sudo mv uv-sbom /usr/local/bin/
Linux (x86_64):
curl -LO https://github.com/Taketo-Yoda/uv-sbom/releases/latest/download/uv-sbom-x86_64-unknown-linux-gnu.tar.gz
tar xzf uv-sbom-x86_64-unknown-linux-gnu.tar.gz
sudo mv uv-sbom /usr/local/bin/
Windows:
Download uv-sbom-x86_64-pc-windows-msvc.zip from the releases page and extract to your desired location.
# Clone the repository
git clone https://github.com/Taketo-Yoda/uv-sbom.git
cd uv-sbom
# Build and install
cargo build --release
cargo install --path .
uv-sbom --version
Generate a CycloneDX JSON SBOM for the current directory:
uv-sbom
Generate a Markdown table with direct and transitive dependencies:
uv-sbom --format markdown
Generate a CycloneDX JSON (default):
uv-sbom --format json
Analyze a project in a different directory:
uv-sbom --path /path/to/project
Output to a file instead of stdout:
uv-sbom --format json --output sbom.json
uv-sbom --format markdown --output SBOM.md
uv-sbom --path /path/to/project --format markdown --output SBOM.md
You can exclude specific packages from the SBOM using the --exclude or -e option:
# Exclude a single package
uv-sbom -e "pytest"
# Exclude multiple packages
uv-sbom -e "pytest" -e "mypy" -e "black"
# Use wildcards to exclude patterns
uv-sbom -e "debug-*" # Exclude all packages starting with "debug-"
uv-sbom -e "*-dev" # Exclude all packages ending with "-dev"
uv-sbom -e "*-test-*" # Exclude all packages containing "-test-"
# Combine with other options
uv-sbom --format json --output sbom.json -e "pytest" -e "*-dev"
Pattern Syntax:
* as a wildcard to match zero or more charactersPreventing Information Leakage:
Use the --exclude option to skip specific internal or proprietary libraries. This prevents their names from being sent to external registries (like PyPI) during metadata retrieval, ensuring your internal project structure remains private.
Use the --check-cve option to check packages for known security vulnerabilities using the OSV (Open Source Vulnerability) database:
# Check for vulnerabilities in Markdown output
uv-sbom --format markdown --check-cve
# Save vulnerability report to file
uv-sbom --format markdown --check-cve --output SBOM.md
# Combine with exclude patterns
uv-sbom --format markdown --check-cve -e "pytest" -e "*-dev"
You can control which vulnerabilities trigger a non-zero exit code using threshold options:
# Check for any vulnerabilities (exits with 1 if found)
uv-sbom --format markdown --check-cve
# Check for High or Critical severity only
uv-sbom --format markdown --check-cve --severity-threshold high
# Check for Critical severity only
uv-sbom --format markdown --check-cve --severity-threshold critical
# Check for CVSS >= 7.0 only
uv-sbom --format markdown --check-cve --cvss-threshold 7.0
# Check for CVSS >= 9.0 (Critical) only
uv-sbom --format markdown --check-cve --cvss-threshold 9.0
Threshold Options:
--severity-threshold <LEVEL>: Filter by severity level (low, medium, high, critical)--cvss-threshold <SCORE>: Filter by CVSS score (0.0-10.0)Notes:
--check-cve to be enabled--cvss-threshold, vulnerabilities without CVSS scores (N/A) are excluded from threshold evaluationUse vulnerability thresholds for CI/CD pipeline integration:
# GitHub Actions example
- name: Generate SBOM
run: uv-sbom --format markdown --output sbom.md
- name: Security Check (High and Critical only)
run: uv-sbom --format markdown --check-cve --severity-threshold high
- name: Security Check (CVSS >= 7.0)
run: uv-sbom --format markdown --check-cve --cvss-threshold 7.0
# GitLab CI example
security_scan:
script:
- uv-sbom --format markdown --check-cve --severity-threshold high
allow_failure: false
Important Notes:
--dry-run mode (skips network operations)--exclude to prevent internal packages from being sent to OSV APIExample Output:
When vulnerabilities are found, a section like this is added to the Markdown output:
## Vulnerability Report
**⚠️ Security Issues Detected**
The following packages have known security vulnerabilities:
| Package | Current Version | Fixed Version | CVSS | Severity | CVE ID |
|---------|----------------|---------------|------|----------|--------|
| urllib3 | 2.0.0 | 2.0.7 | 9.8 | 🔴 CRITICAL | CVE-2023-45803 |
| requests | 2.28.0 | 2.31.0 | 7.5 | 🟠 HIGH | CVE-2023-32681 |
---
*Vulnerability data provided by [OSV](https://osv.dev) under CC-BY 4.0*
When no vulnerabilities are found:
## Vulnerability Report
**✅ No Known Vulnerabilities**
No security vulnerabilities were found in the scanned packages.
---
*Vulnerability data provided by [OSV](https://osv.dev) under CC-BY 4.0*
Use the --dry-run option to validate your configuration before the tool communicates with external registries:
# Verify exclude patterns work correctly
uv-sbom --dry-run -e "internal-*" -e "proprietary-pkg"
# Test configuration with all options
uv-sbom --dry-run --path /path/to/project --format json -e "*-dev"
Why use --dry-run:
--exclude patterns correctly match the packages you want to skipWhat happens in dry-run mode:
uv.lock fileThe -e/--exclude option implements the following security measures to protect against malicious input:
Only the following characters are allowed in patterns:
-), underscores (_), dots (.): Common in package names[, ]): For package extras (e.g., requests[security])*): For wildcard matchingControl characters, shell metacharacters, and path separators are blocked to prevent:
These limits prevent denial-of-service attacks via:
Valid patterns:
uv-sbom -e 'pytest' # Exact match
uv-sbom -e 'test-*' # Prefix wildcard
uv-sbom -e '*-dev' # Suffix wildcard
uv-sbom -e 'package[extra]' # Package with extras
Invalid patterns (rejected with error):
uv-sbom -e '' # Empty pattern
uv-sbom -e '***' # Only wildcards
uv-sbom -e 'pkg;rm -rf /' # Contains shell metacharacter
uv-sbom -e "$(cat /etc/passwd)" # Shell command substitution blocked
For more detailed security information, including threat model and attack vectors, see SECURITY.md.
Options:
-f, --format <FORMAT> Output format: json or markdown [default: json]
-p, --path <PATH> Path to the project directory [default: current directory]
-o, --output <OUTPUT> Output file path (if not specified, outputs to stdout)
-e, --exclude <PATTERN> Exclude packages matching patterns (supports wildcards: *)
--dry-run Validate configuration without network communication or output generation
--check-cve Check for known vulnerabilities using OSV API (Markdown format only)
--severity-threshold <LEVEL> Severity threshold for vulnerability check (low/medium/high/critical)
Requires --check-cve to be enabled
--cvss-threshold <SCORE> CVSS threshold for vulnerability check (0.0-10.0)
Requires --check-cve to be enabled
-h, --help Print help
-V, --version Print version
uv-sbom returns the following exit codes:
| Exit Code | Description | Examples |
|---|---|---|
| 0 | Success | SBOM generated successfully, no vulnerabilities above threshold, --help or --version displayed |
| 1 | Vulnerabilities detected (with --check-cve) |
Vulnerabilities above threshold detected |
| 2 | Invalid command-line arguments | Unknown option, invalid argument type |
| 3 | Application error | Missing uv.lock file, invalid project path, invalid exclude pattern, network error, file write error |
When using --check-cve, the exit code behavior changes based on threshold settings:
| Scenario | Exit Code |
|---|---|
| No vulnerabilities found | 0 |
| Vulnerabilities found (no threshold specified) | 1 |
| Vulnerabilities found, all below threshold | 0 |
| Vulnerabilities found, some above threshold | 1 |
Examples:
# Returns 0 if no High/Critical vulnerabilities, even if Low/Medium exist
uv-sbom --format markdown --check-cve --severity-threshold high
# Returns 0 if no vulnerabilities have CVSS >= 7.0
uv-sbom --format markdown --check-cve --cvss-threshold 7.0
Exit code 1 - Application errors:
# Missing uv.lock file
$ uv-sbom --path /path/without/uv-lock
❌ An error occurred:
uv.lock file not found: /path/without/uv-lock/uv.lock
# Exit code: 1
# Invalid exclude pattern (empty)
$ uv-sbom -e ""
❌ An error occurred:
Exclusion pattern cannot be empty
# Exit code: 1
# Invalid exclude pattern (invalid characters)
$ uv-sbom -e "pkg;name"
❌ An error occurred:
Exclusion pattern contains invalid character ';' in pattern 'pkg;name'
# Exit code: 1
# Nonexistent project path
$ uv-sbom --path /nonexistent
❌ An error occurred:
Invalid project path: /nonexistent
# Exit code: 1
Exit code 2 - CLI argument errors:
# Unknown option
$ uv-sbom --unknown-option
error: unexpected argument '--unknown-option' found
# Exit code: 2
# Invalid format value
$ uv-sbom --format invalid
error: invalid value 'invalid' for '--format <FORMAT>'
# Exit code: 2
#!/bin/bash
uv-sbom --format json --output sbom.json
case $? in
0)
echo "SBOM generated successfully"
;;
1)
echo "Application error occurred"
exit 1
;;
2)
echo "Invalid command-line arguments"
exit 2
;;
esac
Note: The Markdown format sample is based on the SBOM format from ja-complete v0.1.0.
# Software Bill of Materials (SBOM)
## Component Inventory
A comprehensive list of all software components and libraries included in this project.
| Package | Version | License | Description |
|---------|---------|---------|-------------|
| janome | 0.5.0 | AL2 | Japanese morphological analysis engine. |
| pydantic | 2.12.5 | MIT | Data validation using Python type hints |
| ...additional packages... |
## Direct Dependencies
Primary packages explicitly defined in the project configuration(e.g., pyproject.toml).
| Package | Version | License | Description |
|---------|---------|---------|-------------|
| janome | 0.5.0 | AL2 | Japanese morphological analysis engine. |
| pydantic | 2.12.5 | MIT | Data validation using Python type hints |
## Transitive Dependencies
Secondary dependencies introduced by the primary packages.
### Dependencies for pydantic
| Package | Version | License | Description |
|---------|---------|---------|-------------|
| annotated-types | 0.7.0 | MIT License | Reusable constraint types to use with typing.Annotated |
| pydantic-core | 2.41.5 | MIT | Core functionality for Pydantic validation and serialization |
{
"bomFormat": "CycloneDX",
"specVersion": "1.6",
"version": 1,
"serialNumber": "urn:uuid:...",
"metadata": {
"timestamp": "2024-01-01T00:00:00Z",
"tools": [
{
"name": "uv-sbom",
"version": "0.1.0"
}
]
},
"components": [
{
"type": "library",
"name": "requests",
"version": "2.31.0",
"description": "HTTP library for Python",
"licenses": [
{
"license": {
"name": "Apache 2.0"
}
}
],
"purl": "pkg:pypi/requests@2.31.0"
}
]
}
uv with a uv.lock fileuv-sbom makes HTTP requests to the following external services during SBOM generation:
https://pypi.org--dry-run)/pypi/{package_name}/json--check-cve):https://api.osv.dev--check-cve flag is used/v1/querybatch - Batch query for vulnerability IDs/v1/vulns/{vuln_id} - Detailed vulnerability informationIf you are behind a corporate firewall or proxy, ensure the following domains are on the allowlist:
# Required
pypi.org
# Optional (only for --check-cve)
api.osv.dev
The tool respects standard HTTP/HTTPS proxy environment variables:
export HTTP_PROXY=http://proxy.company.com:8080
export HTTPS_PROXY=http://proxy.company.com:8080
export NO_PROXY=localhost,127.0.0.1
uv-sbom --format json
To validate configuration without making network requests, use --dry-run:
uv-sbom --dry-run
This mode:
uv.lock fileuv-sbom provides detailed error messages with helpful suggestions:
Example error message:
❌ An error occurred:
uv.lock file not found: /path/to/project/uv.lock
💡 Hint: uv.lock file does not exist in project directory "/path/to/project".
Please run in the root directory of a uv project, or specify the correct path with the --path option.
Ensure you're running the command in a directory containing a uv.lock file, or use the --path option to specify the correct project directory.
Some packages may fail to retrieve license information from PyPI. The tool will:
If you're behind a proxy or firewall, ensure that you can access https://pypi.org. The tool uses a 10-second timeout for API requests.
These files provide comprehensive context for AI-assisted development with Claude Code.
When using the --check-cve option, this tool retrieves vulnerability data from OSV (Open Source Vulnerability), which is provided under the Creative Commons Attribution 4.0 International License (CC-BY 4.0).
Required Attribution:
The OSV database is a collaborative effort to provide comprehensive, accurate, and accessible vulnerability information for open source software.
MIT License - see LICENSE file for details.