Skip to content

Commit f21425d

Browse files
author
Glenn Snyder
committed
making fix and adding code showing how to retrieve component-version update guidance to remediate vulnerabilities
1 parent 4b0ae1c commit f21425d

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

examples/get_bom_component_policy_violations.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@
3131
project = hub.get_project_by_name(args.project_name)
3232
version = hub.get_version_by_name(project, args.version)
3333

34-
bom_components = hub.get_version_components(version)
34+
if project and version:
35+
bom_components = hub.get_version_components(version)
36+
else:
37+
sys.exit()
3538

3639
all_policy_violations = dict()
3740

examples/get_bom_component_vulnerability_info.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,16 @@
7676
vuln_name = vuln['vulnerabilityWithRemediation']['vulnerabilityName']
7777

7878
# Retrieve additional details about the vulnerability
79+
#
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"
86+
update_guidance_results = hub.execute_get(update_guidance_url).json()
87+
vuln['update_guidance'] = update_guidance_results
88+
7989
logging.debug("Retrieving additional details regarding vuln {}, i={}".format(vuln_name, i))
8090
vuln_url = hub.get_apibase() + "/vulnerabilities/{}".format(vuln_name)
8191
vuln_details_response = hub.execute_get(vuln_url, custom_headers={'Accept': 'application/json'})

0 commit comments

Comments
 (0)