Skip to content

Commit 7d882c7

Browse files
author
Glenn Snyder
committed
fixing the values to supply when updating remediation (aka vulnerability) status
1 parent f1a9807 commit 7d882c7

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

examples/update_vuln_status.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,19 @@
4848
response = hub.execute_get(vulnerable_components_url, custom_headers=custom_headers)
4949
vulnerable_bom_components = response.json().get('items', [])
5050

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+
5161
if hasattr(args, "status"):
5262
# user supplied status
53-
status = args.status.upper()
63+
status = status_keyword_lookup[args.status]
5464
comment = args.comment
5565
else:
5666
default_remediation_status_url = hub.get_apibase() + f"/vulnerabilities/{args.vulnerability}/default-remediation-status"
@@ -66,8 +76,9 @@
6676
vuln['comment'] = comment
6777
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}")
6878
result = hub.execute_put(vuln['_meta']['href'], data=vuln)
79+
6980
if result.status_code == 202:
7081
logging.info(f"Successfully updated vuln {args.vulnerability} in project {project['name']}, version {version['versionName']} with status {status} and comment {comment}")
7182
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}")
7384

0 commit comments

Comments
 (0)