Features
- Automatic Downloads: Default “dca” (deep code analysis) ruleset is automatically fetched on first scan
- Local Caching: Downloaded rulesets are cached at
~/.scanoss/crypto-finder/cache/ - TTL-Based Expiration:
- Pinned versions (e.g.,
v1.0.0): 7 days - Latest versions: 24 hours
- Pinned versions (e.g.,
- Stale Cache Fallback: Automatically uses expired cache (up to 30 days old) when API is unreachable (opt-out with
--strict) - Checksum Verification: SHA256 verification ensures ruleset integrity
- Retry Logic: Automatic retry with exponential backoff on network failures
- Seamless Integration: Combine remote and local rules effortlessly
Configuration
1. API Key Setup
You can configure your API key using one of three methods (in priority order):2. API URL (Optional)
The default API URL ishttps://api.scanoss.com. To use a custom instance:
Usage Examples
Cache Management
Cache Location
Cache Behavior
- First scan: Downloads and caches the default “dca” ruleset
- Subsequent scans: Uses cached version if not expired
- Expired cache: Automatically re-downloads on next scan
- API unreachable + expired cache: Uses stale cache as fallback (if within max age limit)
- Manual cleanup: Simply delete
~/.scanoss/crypto-finder/cache/
Stale Cache Fallback (Default Behavior)
When the cache expires and the API is unreachable, crypto-finder automatically falls back to the expired cache if it’s within the maximum stale age (default: 30 days): Flow:- Check if cache is valid (not expired)
- ✅ Valid → Use cached rules
- Cache expired → Try to download fresh rules from API
- ✅ API reachable → Download and update cache
- ❌ API unreachable → Check stale cache fallback:
- If cache age ≤ max stale age (30 days) → Use stale cache with warning
- If cache age > max stale age → Fail with error
- If
--strictflag enabled → Fail with error
- Resilience: Transient API issues don’t block scans
- CI/CD Reliability: Pipelines don’t fail due to infrastructure problems
- Offline Capability: Continue scanning with slightly stale rules
--strict:
- Compliance audits requiring fresh rules
- Security-critical scans where staleness is unacceptable
- Environments where failure is preferred over using outdated rules
Troubleshooting
No API Key Error
Cache Not Available / Air-Gapped Environments
If you’re in an air-gapped environment and need to use cached rules: Solution:- Run a scan while connected to download and cache rulesets
- Transfer the cache directory (
~/.scanoss/crypto-finder/cache/) to the air-gapped environment - The tool will automatically use the cache within the TTL period (24h for latest, 7d for pinned versions)
- After TTL expires, scans will use stale cache fallback (up to 30 days) with a warning
- For long-term offline use, consider using
--no-remote-rules --rules-dirwith local rules
API Unreachable / Network Timeout
When the API is unreachable and expired cache exists, crypto-finder will automatically fall back to stale cache with a warning: Example Warning:- Scan continues successfully using stale cache
- Warning is logged to stderr
- Exit code is 0 (success)
Cache Too Stale
If cached rules exceed the maximum stale age (default: 30 days), the scan will fail: Error:- Wait for API to recover and retry
- Increase max stale age (up to 90 days):
- Use local rules instead:
Best Practices
- Initial Setup: Configure API key once using
crypto-finder configure --api-key <key> - Hybrid Approach: Combine remote rules with project-specific local rules for customization
- CI/CD Pipelines:
- Use environment variable
SCANOSS_API_KEYfor secure key management - Default behavior (with stale cache fallback) is recommended for most pipelines to prevent failures due to transient API issues
- Use
--strictfor compliance-critical pipelines where fresh rules are mandatory - Consider using
--max-stale-ageto tune the acceptable staleness window (e.g.,--max-stale-age 7dfor 7 days)
- Use environment variable
- Offline/Air-Gapped Environments:
- Pre-cache rules before going offline
- Stale cache fallback provides up to 30 days of grace period (configurable to 90 days)
- For longer periods, use
--no-remote-rules --rules-dirwith local rules