@@ -70,12 +70,12 @@ def get_findings(self, file, test):
7070
7171 if "threatAction" in threat :
7272 title = threat ["threatAction" ]
73- severity , impact , comments = self .parse_threat_metadata (threat [ "metadata" ] )
73+ severity , impact , comments = self .parse_threat_metadata (threat . get ( "metadata" , []) )
7474 description = self .to_description_text (threat , comments , assumption_threat_links [threat ["id" ]])
7575 mitigation = self .to_mitigation_text (mitigation_links [threat ["id" ]])
7676 unique_id_from_tool = threat ["id" ]
7777 vuln_id_from_tool = threat ["numericId" ]
78- tags = threat [ "tags" ] if "tags" in threat else []
78+ tags = threat . get ( "tags" , [])
7979
8080 finding = Finding (
8181 title = title ,
@@ -112,14 +112,12 @@ def to_mitigation_text(self, mitigations):
112112 counti = i + 1
113113 text += f"**Mitigation { counti } (ID: { mitigation ['numericId' ]} , Status: { mitigation .get ('status' , 'Not defined' )} )**: { mitigation ['content' ]} "
114114
115- for item in mitigation [ "metadata" ] :
115+ for item in mitigation . get ( "metadata" , []) :
116116 if item ["key" ] == "Comments" :
117117 text += f"\n *Comments*: { item ['value' ].replace (linesep , ' ' )} "
118118 break
119119
120- for j , assumption in enumerate (assumption_links ):
121- countj = j + 1
122- text += f"\n - *Assumption { countj } (ID: { assumption ['numericId' ]} )*: { assumption ['content' ].replace (linesep , ' ' )} "
120+ text += self .to_assumption_text (assumption_links )
123121
124122 text += "\n "
125123
@@ -145,8 +143,19 @@ def to_description_text(self, threat, comments, assumption_links):
145143 if comments :
146144 text += f"\n *Comments*: { comments } "
147145
146+ text += self .to_assumption_text (assumption_links )
147+
148+ return text
149+
150+ def to_assumption_text (self , assumption_links ):
151+ text = ""
148152 for i , assumption in enumerate (assumption_links ):
149153 counti = i + 1
150154 text += f"\n - *Assumption { counti } (ID: { assumption ['numericId' ]} )*: { assumption ['content' ].replace (linesep , ' ' )} "
151155
156+ for item in assumption .get ("metadata" , []):
157+ if item ["key" ] == "Comments" :
158+ text += f"\n *Comments*: { item ['value' ].replace (linesep , ' ' )} "
159+ break
160+
152161 return text
0 commit comments