|
78 | 78 | # Retrieve additional details about the vulnerability
|
79 | 79 | #
|
80 | 80 |
|
81 |
| - # As per https://jira-sig.internal.synopsys.com/browse/HUB-16455 |
82 |
| - # update guidance can be found on an un-documented, public API endpoint |
83 |
| - # of the form, /api/components/{component_id}/versions/{version_id}/remediating |
84 |
| - # |
85 |
| - update_guidance_url = vuln['componentVersion'] + "/remediating" |
| 81 | + update_guidance_url = vuln['componentVersion'] + "/upgrade-guidance" |
86 | 82 | update_guidance_results = hub.execute_get(update_guidance_url).json()
|
87 | 83 | vuln['update_guidance'] = update_guidance_results
|
88 | 84 |
|
|
117 | 113 | else:
|
118 | 114 | logging.debug("Did not find any vulnerable BOM components in project {}, version {}".format(args.project_name, args.version))
|
119 | 115 |
|
120 |
| -print(json.dumps(vulnerable_bom_components)) |
| 116 | +# Combine counts and vulnerabilities (aka vulnerable bom components) |
| 117 | +# |
| 118 | +num_bdsa_records = len(list(filter(lambda v: v['vulnerabilityWithRemediation']['source'] == 'BDSA', |
| 119 | + vulnerable_bom_components))) |
| 120 | +num_nvd_records = len(list(filter(lambda v: v['vulnerabilityWithRemediation']['source'] == 'NVD', |
| 121 | + vulnerable_bom_components))) |
| 122 | + |
| 123 | +remediation_counts = {} |
| 124 | +remediation_statuses = [v['vulnerabilityWithRemediation']['remediationStatus'] for v in vulnerable_bom_components] |
| 125 | +for status in remediation_statuses: |
| 126 | + remediation_counts[status] = remediation_counts.get(status, 0) + 1 |
| 127 | + |
| 128 | +counts = { |
| 129 | + 'BDSA': num_bdsa_records, |
| 130 | + 'NVD': num_nvd_records, |
| 131 | + 'all_vulns': num_bdsa_records + num_nvd_records, |
| 132 | + 'by_remediation_status': remediation_counts |
| 133 | +} |
| 134 | + |
| 135 | + |
| 136 | +everything = { |
| 137 | + 'counts': counts, |
| 138 | + 'vulnerabilities': vulnerable_bom_components |
| 139 | +} |
| 140 | + |
| 141 | +print(json.dumps(everything)) |
121 | 142 |
|
0 commit comments