Skip to content

Commit 359e968

Browse files
committed
bugfix: Vulnerability summary key error
1 parent d1228a4 commit 359e968

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

codeinsight_sdk/experimental.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,21 @@ def get_project_vulnerabilities(
3232
item: ProjectInventoryItem
3333
vuln_items: list(ProjectInventoryItem) = []
3434
for item in inventory:
35-
if item.vulnerabilitySummary is None:
35+
if item.vulnerabilitySummary is None or len(item.vulnerabilitySummary) == 0:
3636
continue
3737

3838
# If the item has a vulnerability, get the vulnerability details for this item and append it
39-
if sum(item.vulnerabilitySummary[0]["CvssV3"].values()) > 0:
39+
item_vul_summary = item.vulnerabilitySummary[0]
40+
k = ""
41+
if "CvssV2" in item_vul_summary.keys():
42+
k = "CvssV2"
43+
elif "CvssV3" in item_vul_summary.keys():
44+
k = "CvssV3"
45+
else:
46+
# If the item has no vulnerabilities, skip it
47+
continue
48+
49+
if sum(item_vul_summary[k].values()) > 0:
4050
vul_detail = self.client.inventories.get_inventory_vulnerabilities(
4151
item.id
4252
)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "codeinsight_sdk"
3-
version = "0.0.9"
3+
version = "0.0.10"
44
description = "A Python client for the Revenera Code Insight"
55
authors = ["Zachary Karpinski <1206496+zkarpinski@users.noreply.github.com>"]
66
readme = "README.md"

tests/test_experimental.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ def test_get_project_vulnerabilities(self, client):
4040
"createdOn":"Today",
4141
"updatedOn":"Tomorrow",
4242
"componentName":"snakeyaml",
43-
"componentVersionName":"2.0"
43+
"componentVersionName":"2.0",
44+
"vulnerabilitySummary": []
4445
},
4546
{
4647
"itemNumber": 2,

0 commit comments

Comments
 (0)