Skip to content

Commit 5953039

Browse files
Fix CWE parsing bug in notify.py
Grype returns CWEs as a list of dicts with structure {"id": "CWE-79"}, not as plain strings. Updated get_cwes() to handle both formats. Fixes TypeError: sequence item 0: expected str instance, dict found Signed-off-by: peter-at-progress <parsenau@progress.com> Signed-off-by: Peter Arsenault <parsenau@progress.com>
1 parent 6c9459a commit 5953039

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

.github/actions/notify-new-cves/notify.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,17 @@ def get_cwes(self) -> list[str]:
138138
"""Get list of CWE IDs."""
139139
cwes = self.vulnerability.get("cwes", [])
140140
if isinstance(cwes, list):
141-
return [cwe for cwe in cwes if cwe]
141+
result = []
142+
for cwe in cwes:
143+
if isinstance(cwe, dict):
144+
# Grype format: {"id": "CWE-79", "name": "..."}
145+
cwe_id = cwe.get("id", "")
146+
if cwe_id:
147+
result.append(cwe_id)
148+
elif isinstance(cwe, str) and cwe:
149+
# Plain string format
150+
result.append(cwe)
151+
return result
142152
return []
143153

144154
def get_urls(self) -> list[str]:

0 commit comments

Comments
 (0)