A command-line tool for analyzing vulnerability metrics in Contrast Security applications.
Project description
contrast-vulnerability-metrics
A command-line tool for analyzing vulnerability metrics and time-to-remediation in Contrast Security applications. This tool helps analyze vulnerability trends and remediation timelines across your application portfolio.
Features
- Fast, asynchronous API querying with concurrent requests
- Configurable date ranges for analysis
- Progress tracking for large datasets
- CSV export for detailed metrics
- Summary statistics by severity level
- Configurable batch size and concurrency
- Environment-based configuration
- Rich terminal output with color-coded results
- Enhanced error handling and retry logic
Installation
- Install:
pip install contrast-vulnerability-metrics
- Create a
.envfile with your Contrast Security credentials:
CONTRAST_BASE_URL=https://app.contrastsecurity.com/Contrast
CONTRAST_ORG_UUID=your-org-uuid
CONTRAST_API_KEY=your-api-key
CONTRAST_AUTH=your-auth-header
Usage
Basic usage:
contrast-vulnerability-metrics analyze
With all options:
contrast-vulnerability-metrics analyze \
--csv output.csv \
--batch-size 200 \
--concurrent-requests 20 \
--use-closed-time \
--start-date 2024-01-01 \
--end-date 2024-03-31 \
--verbose
Options
--csv: Output file path for detailed CSV results--batch-size: Number of vulnerabilities to fetch per request (default: 100)--concurrent-requests: Maximum number of concurrent API requests (default: 10)--use-closed-time/--use-last-seen: Use closed_time instead of last_time_seen for remediation calculations (default: use closed time)--start-date: Start date for filtering (YYYY-MM-DD format)--end-date: End date for filtering (YYYY-MM-DD format)--days-back: Number of days back from today to include--verbose: Enable verbose logging
Output
The tool provides a summary of vulnerability metrics including average and median time-to-remediation by severity level:
Example output:
Vulnerability Metrics Summary
╭──────────┬────────────────────┬─────────────────────┬───────╮
│ │ Avg Time to Close │ Median Time to │ │
│ Severity │ (Days) │ Close (Days) │ Count │
├──────────┼────────────────────┼─────────────────────┼───────┤
│ CRITICAL │ 658 │ 656 │ 4 │
│ HIGH │ 158 │ 158 │ 1 │
│ MEDIUM │ 1635 │ 1635 │ 1 │
│ OVERALL │ 737 │ 656 │ 6 │
╰──────────┴────────────────────┴─────────────────────┴───────╯
CSV Output Format
The CSV output includes two sections:
- Summary statistics by severity
- Detailed vulnerability metrics including:
- UUID
- Severity
- First Seen
- Last Seen
- Closed Time
- Days to Last Seen
- Days to Remediation
Environment Variables
| Variable | Description | Example |
|---|---|---|
| CONTRAST_BASE_URL | Contrast Security API URL | https://app.contrastsecurity.com/Contrast |
| CONTRAST_ORG_UUID | Organization UUID | 12345678-90ab-cdef-1234-567890abcdef |
| CONTRAST_API_KEY | API Key | your-api-key |
| CONTRAST_AUTH | Authorization header | base64-encoded-credentials |
Development
Requirements:
- Python 3.8+
- httpx
- typer
- rich
- python-dotenv
- tqdm
License
MIT License
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Run the tests
- Submit a pull request
Support
For issues, questions, or contributions, please open an issue in the GitHub repository.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file contrast_vulnerability_metrics-0.1.0.tar.gz.
File metadata
- Download URL: contrast_vulnerability_metrics-0.1.0.tar.gz
- Upload date:
- Size: 15.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.26
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
90df6e3794da82b5a5a0bc4bab50ebea05b0bb58c8df544546c70dda10cfd89e
|
|
| MD5 |
9c46bd01f1b7cb0118187224199e50c2
|
|
| BLAKE2b-256 |
6a5863213cf3e3bb1a8d7a08b8b0faf120d63eb2a4f06dea4bdd34401180bac8
|
File details
Details for the file contrast_vulnerability_metrics-0.1.0-py3-none-any.whl.
File metadata
- Download URL: contrast_vulnerability_metrics-0.1.0-py3-none-any.whl
- Upload date:
- Size: 15.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.26
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d8f330629191c4de9693023d2d99a9ebdc2ef1c09fabfb2214819dfdb469eeea
|
|
| MD5 |
baffb898c24e382d24efefabca94c428
|
|
| BLAKE2b-256 |
ae628f4da8e18bf79d8e4c252c760ab69576c8f5d62c5b9e7c0c9693f8ad3ede
|