Skip to content

Commit 9e97795

Browse files
committed
fix: handle objects without descriptions in changelog, like detection strategies
1 parent 9908911 commit 9e97795

1 file changed

Lines changed: 10 additions & 9 deletions

File tree

mitreattack/diffStix/changelog_helper.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -372,15 +372,16 @@ def load_data(self):
372372

373373
# Description changes
374374
#####################
375-
old_lines = old_stix_obj["description"].replace("\n", " ").splitlines()
376-
new_lines = new_stix_obj["description"].replace("\n", " ").splitlines()
377-
old_lines_unique = [line for line in old_lines if line not in new_lines]
378-
new_lines_unique = [line for line in new_lines if line not in old_lines]
379-
if old_lines_unique or new_lines_unique:
380-
html_diff = difflib.HtmlDiff(wrapcolumn=60)
381-
html_diff._legend = "" # type: ignore[attr-defined]
382-
delta = html_diff.make_table(old_lines, new_lines, "Old Description", "New Description")
383-
new_stix_obj["description_change_table"] = delta
375+
if "description" in old_stix_obj and "description" in new_stix_obj:
376+
old_lines = old_stix_obj["description"].replace("\n", " ").splitlines()
377+
new_lines = new_stix_obj["description"].replace("\n", " ").splitlines()
378+
old_lines_unique = [line for line in old_lines if line not in new_lines]
379+
new_lines_unique = [line for line in new_lines if line not in old_lines]
380+
if old_lines_unique or new_lines_unique:
381+
html_diff = difflib.HtmlDiff(wrapcolumn=60)
382+
html_diff._legend = "" # type: ignore[attr-defined]
383+
delta = html_diff.make_table(old_lines, new_lines, "Old Description", "New Description")
384+
new_stix_obj["description_change_table"] = delta
384385

385386
# Relationship changes
386387
######################

0 commit comments

Comments
 (0)