Black Duck Remediation Metrics
A Python module for extracting and analyzing remediation status metrics from Black Duck.
Description
This script is used to export remediation status for a given level. By default, the script exports the status for all projects in a given Black Duck instance. There are filtering options implemented to limit the project count.
Features
- Export remediation status for all projects in a Black Duck instance
- Filter by project groups (including recursive sub-groups)
- Filter by specific projects and versions
- Filter by phase categories (PLANNING, DEVELOPMENT, RELEASED, DEPRECATED, ARCHIVED, PRERELEASE)
- Filter by distribution categories (EXTERNAL, SAAS, INTERNAL, OPENSOURCE)
- Generate HTML, PDF, and JSON reports
- Generate interactive dashboards with charts and visualizations
- Cache support for improved performance
- Progress tracking with progress bars
Installation
From PyPI (when published)
pip install blackduck-remediation-metrics
From source
git clone https://github.com/jounilehto/blackduck-remediation-metrics.git
cd blackduck-remediation-metrics
pip install -e .[dev]
Requirements
- Python 3.8 or higher
- wkhtmltopdf (for PDF generation) - Download from https://wkhtmltopdf.org/
Optional Dependencies
For enhanced dashboard features with Playwright:
pip install blackduck-remediation-metrics[playwright]
playwright install
Usage
Getting an Access Token
To get an Access Token, use your Internet browser and go to:
<BD_URL>/api/current-user/tokens?limit=100&offset=0
Click "+ Create Token", give it a name and Scope: "Read and Write Access", then click "Create". Copy and paste the given access token.
NOTE: After you click "Close", you cannot see the token anymore.
Command Line Interface
Print version
bd-metrics --version
# or
bd-metrics -v
Generate HTML and PDF reports for all projects
bd-metrics --token="<ACCESS_TOKEN>" --url="<BD_URL>" --html --pdf --json
Generate interactive dashboard
bd-metrics --token="<ACCESS_TOKEN>" --url="<BD_URL>" --dashboard --json
Use cache for improved performance
bd-metrics --token="<ACCESS_TOKEN>" --url="<BD_URL>" --cache --html --pdf --json
Filter by project group
bd-metrics --token="<ACCESS_TOKEN>" --url="<BD_URL>" --project-group="<PROJECT_GROUP_NAME>" --html --pdf
Filter by specific project and version
bd-metrics --token="<ACCESS_TOKEN>" --url="<BD_URL>" --project="<PROJECT_NAME>" --project-version="<PROJECT_VERSION_NAME>" --html --pdf
Filter by phase categories
bd-metrics --token="<ACCESS_TOKEN>" --url="<BD_URL>" --phaseCategories="PLANNING,DEVELOPMENT" --html --pdf
Filter by distribution categories
bd-metrics --token="<ACCESS_TOKEN>" --url="<BD_URL>" --distributionCategories="EXTERNAL" --html
Specify output directory
bd-metrics --token="<ACCESS_TOKEN>" --url="<BD_URL>" --dir="./reports" --html --pdf
Command-Line Parameters
Required Parameters
| Parameter | Description | Environment Variable |
|---|---|---|
--url |
Base URL for Black Duck Hub | BD_URL |
--token |
Black Duck access token | BD_TOKEN |
Note: Both parameters can be set via environment variables instead of command-line arguments.
Project/Version Filtering
| Parameter | Description | Default |
|---|---|---|
--project |
Filter by specific Black Duck project name | None (all projects) |
--project-version |
Filter by specific project version name (requires --project) |
None (all versions) |
--project-group |
Filter by project group name (includes sub-groups recursively) | None |
Phase and Distribution Filtering
| Parameter | Description | Default | Options |
|---|---|---|---|
--phaseCategories |
Comma-separated list of version phases to include | All phases | PLANNING, DEVELOPMENT, RELEASED, DEPRECATED, ARCHIVED, PRERELEASE |
--distributionCategories |
Comma-separated list of version distributions to include | All distributions | EXTERNAL, SAAS, INTERNAL, OPENSOURCE |
Report Generation Options
| Parameter | Description | Type |
|---|---|---|
--html |
Generate HTML report | Flag |
--pdf |
Generate PDF report (requires wkhtmltopdf) | Flag |
--json |
Generate JSON report | Flag |
--csv |
Generate CSV report | Flag |
--dashboard |
Generate interactive dashboard HTML report with charts | Flag |
Note: You can specify multiple report types in a single run.
Cache and Database Options
| Parameter | Description | Default |
|---|---|---|
--cache |
Use TinyDB as a cache for improved performance on subsequent runs | Disabled |
--db_file |
TinyDB database file path | bd_remediation_db.json |
--cache_truncate |
Clean/truncate the cache file before running | Disabled |
Output and Logging Options
| Parameter | Description | Default |
|---|---|---|
-v, --version |
Display version information and exit | N/A |
--dir |
Output directory for generated reports | . (current directory) |
--log_level |
Logging level for console output | INFO |
--sinceDays |
Number of days to mark project versions as dormant (shows warning icon) | 30 |
--compress |
Gzip-compress HTML and dashboard output files (.html.gz); all modern browsers open these natively |
Disabled |
--show-empty |
Show project/version rows with all-zero counts in the triage status HTML report (hidden by default) | Disabled |
Environment Variables
You can set token and URL parameters as environment variables:
export BD_TOKEN="<BD_TOKEN>"
export BD_URL="<BD_URL>"
Then run without --token and --url arguments:
bd-metrics --html --pdf
Proxy Configuration
If a proxy is needed, use the export method:
export HTTP_PROXY='http://10.10.10.10:8000'
export HTTPS_PROXY='https://10.10.10.10:1212'
Using as a Python Module
from blackduck_remediation_metrics import main
# Call the main function (sys.argv will be used for arguments)
main()
Or run as a module:
python -m blackduck_remediation_metrics --token="<ACCESS_TOKEN>" --url="<BD_URL>" --html
Project Structure
blackduck-remediation-metrics/
├── src/
│ └── blackduck_remediation_metrics/
│ ├── __init__.py
│ ├── __main__.py
│ ├── blackduck_triage_extract.py
│ └── templates/
│ ├── BD_Results_Distribution_by_Triage_Status_v3.html
│ └── BD_Results_Triage_Dashboard.html
├── tests/
├── pyproject.toml
├── requirements.txt
├── setup.py
├── README.md
└── LICENSE
Version History
- 0.1.22 - Added
--compressflag to gzip HTML and dashboard output files for significantly reduced file sizes - 0.1.21 - Added
--show-emptyflag for triage report, version-level zero filtering, sortable dashboard table, hide-empty-rows toggle in dashboard - 0.1.20 - Added -v/--version flag, renamed parameters to --project-version and --project-group for consistency
- 0.1.19 - Added comprehensive command-line parameter documentation to README
- 0.1.18 - Fixed pyproject.toml license configuration for PEP 639 compliance
- 0.1.17 - Added new look and feel, added policy violations, added data visualization
- 0.1.16 - Added link to policy violation from policy name in the report
- 0.1.15 - Fixed issue where totalCount key was missing
- 0.1.14 - Fixed issue where key word snippetScanPresent was missing
- 0.1.13 - Added missing remediation statuses UNDER_INVESTIGATION and AFFECTED
- 0.1.12 - Fixed issues where there might be vulnerabilities without severity
- 0.1.11 - Added NOT_AFFECTED remediation type and removed BetterJSONStorage usage
- 0.1.10 - Added progressbar using tqdm to show progress of project analysis phases
- 0.1.9 - Added feature to export report in JSON format
- 0.1.8 - Added check if project has updated compared to last run
- 0.1.7 - Changed to use BetterJSONStorage to improve performance and reduce database size
- 0.1.6 - Added triangle icon and last scanned date for project versions
- 0.1.5 - Added usage of TinyDB for caching BD metrics
License
MIT License
Author
Jouni Lehto
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Support
For issues and questions, please use the GitHub issue tracker.
Metadata
Release files for blackduck-remediation-metrics 0.1.23
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| blackduck_remediation_metrics-0.1.23.tar.gz | 37.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| blackduck_remediation_metrics-0.1.23-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 73.8 kB
Release files / blackduck_remediation_metrics-0.1.23.tar.gz
| Download URL | blackduck_remediation_metrics-0.1.23.tar.gz |
|---|---|
| Size | 37.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
080fcfb21ebe62f726ea60c6102dd1574e5fb67e7876e3821e2ea96377a50e5a
|
|
BLAKE2b-256 checksum How to use checksums |
6d33d15ee75c8055a336f840be052a3c4f283075588c63766fa434f4e987487a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.6
|
Release files / blackduck_remediation_metrics-0.1.23-py3-none-any.whl
| Download URL | blackduck_remediation_metrics-0.1.23-py3-none-any.whl |
|---|---|
| Size | 36.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b643cab35366fab828d4cad38c4eb3f9ff924ea02829a0461df731447f6d9f55
|
|
BLAKE2b-256 checksum How to use checksums |
19bce84540455ebf90f0998f4ef435680c67178ab74fd26e646ccf18a872af65
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.6
|