rust_secure_dependency_audit
A comprehensive tool for auditing Rust project dependencies, providing insights into health, maintenance status, license compliance, and supply-chain risks.
Why This Tool?
Modern software projects depend on dozens or hundreds of external crates. While Rust's ecosystem is generally well-maintained, dependencies can become:
- Stale: Not updated in months or years
- Unmaintained: Original authors have moved on
- Risky: Security issues, licensing problems, or abandoned repositories
- Bloated: Excessive footprint for embedded/mobile projects
This tool helps you identify and mitigate these risks by analyzing:
- 📊 Health scoring: Weighted algorithm considering recency, maintenance, community, and stability
- 📜 License analysis: Categorize licenses (permissive, copyleft, proprietary) and detect compliance issues
- 📦 Footprint estimation: Identify dependencies that may bloat your binary (useful for embedded/mobile)
- 🔍 Metadata aggregation: Fetch data from crates.io, GitHub, and GitLab
Features
- Multi-source metadata: Combines crates.io, GitHub, and GitLab data for comprehensive analysis
- Configurable scoring: Customize weights and thresholds for your project's needs
- Both library and CLI: Use as a library in your tools or run standalone
- Fast parallel processing: Concurrent API calls with rate-limiting protection
- Multiple output formats: JSON and Markdown reports
- CI/CD integration: Exit codes based on thresholds for automated checks
Installation
As a CLI tool
As a library
Add to your Cargo.toml:
[]
= "0.1"
Quick Start
CLI Usage
Scan your project:
Generate a JSON report:
Check with thresholds (for CI):
Scan with failure threshold:
Ignore specific dependencies:
Library Usage
use ;
use Path;
async
How It Works
Health Scoring Algorithm
Each dependency receives a health score (0-100) based on weighted factors:
-
Recency (40%): Days since last publish/commit
- Updated within 30 days: 100
- Within 3 months: 90
- Within 6 months: 80
- Within 1 year: 60
- Within 2 years: 30
- Older: 10
-
Maintenance (30%): Repository activity
- Archived repositories: 0
- Active issues management: +25
- Recent commits: +25
-
Community (20%): Contributors and engagement
- Number of authors/maintainers
- GitHub stars
- Contributor count
-
Stability (10%): Version history
- Number of published versions
- Download count
-
Security (15%): Security practices
- OpenSSF Scorecard: 0-10 score mapped to 0-100
- Security Policy: Presence of
SECURITY.md(+20 points) - Yanked Status: Yanked crates receive a massive penalty (max score 10)
Scores are then categorized:
- 80-100: Healthy 🟢
- 60-79: Warning 🟡
- 40-59: Stale 🟠
- 0-39: Risky 🔴
License Analysis
Licenses are categorized into:
- Permissive: MIT, Apache, BSD, ISC, etc.
- Copyleft: GPL, LGPL, AGPL, MPL, etc.
- Proprietary: Commercial, private licenses
- Unknown: Missing or unrecognized
You can configure:
- Allowed/forbidden license lists
- Warnings on copyleft or unknown licenses
Footprint Estimation
Calculates a footprint risk score (0.0-1.0) based on:
- Transitive dependency count (40%)
- Feature count (30%)
- Build dependency complexity (30%)
Useful for embedded, mobile, or WASM projects where binary size matters.
Configuration
TOML Configuration File
Create a config file (e.g., audit-config.toml):
[]
= 0.50
= 0.30
= 0.15
= 0.15
= 0.10
= 0.15
[]
= 180 # 6 months
= 365 # 1 year
= 2
[]
= ["MIT", "Apache-2.0", "BSD-3-Clause"]
= ["AGPL-3.0"]
= true
= true
[]
= 50
= 0.7
[]
= 30
= 3
= 3
= 100
= true
Use it:
Environment Variables
GITHUB_TOKEN: GitHub personal access token (for higher API rate limits)GITLAB_TOKEN: GitLab personal access token
CLI Reference
Global Options
--project-path <PATH>: Path to Rust project (default: current directory)--config <FILE>: Custom TOML configuration file--ignore <CRATE>: Ignore specific dependencies (repeatable)--verbose: Enable verbose logging
Subcommands
scan
Run full audit and display summary.
Options:
--fail-threshold <SCORE>: Exit with error if any dependency scores below threshold--detailed: Show detailed information for each dependency
report
Generate detailed audit report.
Options:
--format <FORMAT>: Output format (jsonormarkdown)--output <FILE>: Write to file (default: stdout)
check
Check dependencies against thresholds (for CI).
Options:
--min-health-score <SCORE>: Minimum acceptable score (default: 60)--fail-on-copyleft: Fail on copyleft licenses--fail-on-unknown-license: Fail on unknown/missing licenses
Examples
Check the examples/ directory:
basic_usage.rs: Simple audit with default configcustom_config.rs: Custom configuration and filtering
Run examples:
Limitations & Caveats
Rate Limiting
- crates.io: Generally permissive, but may throttle excessive requests
- GitHub: 60 requests/hour unauthenticated, 5000/hour with token
- GitLab: Similar limits
Recommendation: Set GITHUB_TOKEN environment variable to increase limits.
Heuristics Are Not Perfect
- Scoring is based on observable metrics, not code quality audits
- A high score doesn't guarantee security
- Manual review is still recommended for critical dependencies
Network Dependency
- Requires internet access to fetch metadata
- May fail in air-gapped environments
- Use
--ignoreto skip problematic dependencies
Not a Replacement for cargo-audit
This tool focuses on maintenance risk, not known security vulnerabilities. Use in combination with:
cargo-audit: CVE scanningcargo-deny: License and advisory checks
Contributing
Contributions are welcome! Areas for improvement:
- Additional heuristics for health scoring
- Support for more Git platforms (Gitea, etc.)
- Persistent caching of API responses
- Integration with advisory databases
Please open an issue or pull request on GitHub.
License
Licensed under either of:
- MIT License (LICENSE-MIT or http://opensource.org/licenses/MIT)
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
at your option.
Acknowledgments
Built with:
cargo_metadata: Cargo project parsingreqwest: HTTP clientclap: CLI frameworktokio: Async runtime