|
48 | 48 | response = hub.execute_get(vulnerable_components_url, custom_headers=custom_headers)
|
49 | 49 | vulnerable_bom_components = response.json().get('items', [])
|
50 | 50 |
|
| 51 | +status_keyword_lookup = { |
| 52 | + "review": "NEEDS_REVIEW", |
| 53 | + "required": "REMEDIATION_REQUIRED", |
| 54 | + "complete": "REMEDIATION_COMPLETE", |
| 55 | + "mitigated": "MITIGATED", |
| 56 | + "patched": "PATCHED", |
| 57 | + "ignored": "IGNORED", |
| 58 | + "duplicate": "DUPLICATE", |
| 59 | +} |
| 60 | + |
51 | 61 | if hasattr(args, "status"):
|
52 | 62 | # user supplied status
|
53 |
| - status = args.status.upper() |
| 63 | + status = status_keyword_lookup[args.status] |
54 | 64 | comment = args.comment
|
55 | 65 | else:
|
56 | 66 | default_remediation_status_url = hub.get_apibase() + f"/vulnerabilities/{args.vulnerability}/default-remediation-status"
|
|
66 | 76 | vuln['comment'] = comment
|
67 | 77 | logging.debug(f"Updating vuln {args.vulnerability} in project {project['name']}, version {version['versionName']} using URL {vuln['_meta']['href']} with status {status} and comment {comment}")
|
68 | 78 | result = hub.execute_put(vuln['_meta']['href'], data=vuln)
|
| 79 | + |
69 | 80 | if result.status_code == 202:
|
70 | 81 | logging.info(f"Successfully updated vuln {args.vulnerability} in project {project['name']}, version {version['versionName']} with status {status} and comment {comment}")
|
71 | 82 | else:
|
72 |
| - logging.error(f"Failed to update vuln {args.vulnerability} in project {project['name']}, version {version['versionName']}; http status code: {response.status_code}") |
| 83 | + logging.error(f"Failed to update vuln {args.vulnerability} in project {project['name']}, version {version['versionName']}; http status code: {result.status_code}") |
73 | 84 |
|
0 commit comments