34 | 34 |
try:
|
35 | 35 |
tree = ET.fromstring(xml_output)
|
36 | 36 |
except SyntaxError as err:
|
37 | |
print('SyntaxError In xml: %s. %s' % (err, xml_output))
|
|
37 |
print(f'SyntaxError In xml: {err}. {xml_output}')
|
38 | 38 |
return None
|
39 | 39 |
return tree
|
40 | 40 |
|
|
181 | 181 |
sast_issues = []
|
182 | 182 |
for item in tree:
|
183 | 183 |
name = self.issue_types[item.find("issue-type/ref").text]
|
184 | |
source_file = item.attrib["filename"].replace('\\','/')
|
|
184 |
source_file = item.attrib["filename"].replace('\\', '/')
|
185 | 185 |
severity = 0 if item.find("severity-id") is None else int(item.find("severity-id").text)
|
186 | 186 |
description = item.find("fix/item/general/text").text
|
187 | 187 |
resolution = "" if item.find("variant-group/item/issue-information/fix-resolution-text") is None \
|
|
239 | 239 |
data.append(f"Method: {item.find('variant-group/item/issue-information/method-signature').text}")
|
240 | 240 |
if item.find("variant-group/item/issue-information/method-signature2") is not None:
|
241 | 241 |
data.append(f"Location: {item.find('variant-group/item/issue-information/method-signature2').text}")
|
|
242 |
line = item.find("location")
|
|
243 |
highlight = item.find("variant-group/item/issue-information/call-trace/call-invocation/context/highlight")
|
|
244 |
if highlight is not None:
|
|
245 |
data.append(f" {highlight.text}")
|
|
246 |
issue_data["desc"] += "\n" + highlight.text
|
|
247 |
if line is not None and len(line.text.split(':')) > 1 and line.text.split(':')[-1].isdigit():
|
|
248 |
data.append(f"line {line.text.split(':')[-1]}")
|
|
249 |
issue_data["desc"] += f"line {line.text.split(':')[-1]}"
|
242 | 250 |
issue_data['data'] = "\n".join(data)
|
243 | 251 |
sast_issues.append(issue_data)
|
244 | 252 |
return sast_issues
|