|
10 | 10 |
|
11 | 11 | import argparse
|
12 | 12 | import json
|
| 13 | +import logging |
13 | 14 | import time
|
14 | 15 |
|
| 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 | + |
15 | 36 | parser = argparse.ArgumentParser("A program to create reports for a given project-version")
|
16 | 37 | parser.add_argument("project_name")
|
17 | 38 | parser.add_argument("version_name")
|
18 | 39 | parser.add_argument("-z", "--zip_file_name", default="reports.zip")
|
19 | 40 | 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.") |
22 | 43 | parser.add_argument('--format', default='CSV', choices=["CSV"], help="Report format - only CSV available for now")
|
23 | 44 | 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")
|
24 | 45 | 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 | 48 |
|
28 | 49 | hub = HubInstance()
|
29 | 50 |
|
30 |
| -version_name_map = { |
31 |
| - 'version': 'VERSION', |
32 |
| - 'scans': 'CODE_LOCATIONS', |
33 |
| - 'components': 'COMPONENTS', |
34 |
| - 'vulnerabilities': 'SECURITY', |
35 |
| - 'source':'FILES' |
36 |
| -} |
37 |
| - |
38 | 51 | class FailedReportDownload(Exception):
|
39 | 52 | pass
|
40 | 53 |
|
|
0 commit comments