Skip to content

Commit fa13872

Browse files
author
Glenn Snyder
authored
update generate reports (#182)
Update to reflect new reports that can be included
1 parent 8b6dccb commit fa13872

File tree

3 files changed

+25
-12
lines changed

3 files changed

+25
-12
lines changed

blackduck/Reporting.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
logger = logging.getLogger(__name__)
1010

11-
valid_categories = ['VERSION','CODE_LOCATIONS','COMPONENTS','SECURITY','FILES', 'ATTACHMENTS', 'CRYPTO_ALGORITHMS', 'PROJECT_VERSION_CUSTOM_FIELDS', 'BOM_COMPONENT_CUSTOM_FIELDS', 'LICENSE_TERM_FULFILLMENT', 'UPGRADE_GUIDANCE']
11+
valid_categories = ['VERSION','CODE_LOCATIONS','COMPONENTS','SECURITY','FILES', 'ATTACHMENTS', 'CRYPTO_ALGORITHMS', 'PROJECT_VERSION_CUSTOM_FIELDS', 'BOM_COMPONENT_CUSTOM_FIELDS', 'LICENSE_TERM_FULFILLMENT', 'UPGRADE_GUIDANCE', 'VULNERABILITY_MATCH']
1212
valid_report_formats = ["CSV", "JSON"]
1313
def create_version_reports(self, version, report_list, format="CSV"):
1414
assert all(list(map(lambda k: k in valid_categories, report_list))), "One or more selected report categories in {} are not valid ({})".format(

blackduck/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
VERSION = (1, 0, 3)
1+
VERSION = (1, 0, 4)
22

33
__version__ = '.'.join(map(str, VERSION))

examples/generate_csv_reports_for_project_version.py

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,36 @@
1010

1111
import argparse
1212
import json
13+
import logging
1314
import time
1415

16+
logging.basicConfig(
17+
level=logging.DEBUG,
18+
format="[%(asctime)s] {%(module)s:%(lineno)d} %(levelname)s - %(message)s"
19+
)
20+
21+
version_name_map = {
22+
'version': 'VERSION',
23+
'scans': 'CODE_LOCATIONS',
24+
'components': 'COMPONENTS',
25+
'vulnerabilities': 'SECURITY',
26+
'source':'FILES',
27+
'cryptography': 'CRYPTO_ALGORITHMS',
28+
'license_terms': 'LICENSE_TERM_FULFILLMENT',
29+
'component_additional_fields': 'BOM_COMPONENT_CUSTOM_FIELDS',
30+
'project_version_additional_fields': 'PROJECT_VERSION_CUSTOM_FIELDS',
31+
'vulnerability_matches': 'VULNERABILITY_MATCH'
32+
}
33+
34+
all_reports = list(version_name_map.keys())
35+
1536
parser = argparse.ArgumentParser("A program to create reports for a given project-version")
1637
parser.add_argument("project_name")
1738
parser.add_argument("version_name")
1839
parser.add_argument("-z", "--zip_file_name", default="reports.zip")
1940
parser.add_argument("-r", "--reports",
20-
default="version,scans,components,vulnerabilities,source",
21-
help="Comma separated list (no spaces) of the reports to generate - version, scans, components, vulnerabilities, source, and cryptography reports (default: all, except cryptography")
41+
default=",".join(all_reports),
42+
help=f"Comma separated list (no spaces) of the reports to generate - {list(version_name_map.keys())}. Default is all reports.")
2243
parser.add_argument('--format', default='CSV', choices=["CSV"], help="Report format - only CSV available for now")
2344
parser.add_argument('-t', '--tries', default=4, type=int, help="How many times to retry downloading the report, i.e. wait for the report to be generated")
2445
parser.add_argument('-s', '--sleep_time', default=5, type=int, help="The amount of time to sleep in-between (re-)tries to download the report")
@@ -27,14 +48,6 @@
2748

2849
hub = HubInstance()
2950

30-
version_name_map = {
31-
'version': 'VERSION',
32-
'scans': 'CODE_LOCATIONS',
33-
'components': 'COMPONENTS',
34-
'vulnerabilities': 'SECURITY',
35-
'source':'FILES'
36-
}
37-
3851
class FailedReportDownload(Exception):
3952
pass
4053

0 commit comments

Comments
 (0)