def html_report(content):
html = "<div>"
html_type = {'important': "",
'warning': "",
'info': "",
'inverse': ""}
for item in content:
if item.name == "analysis":
decoded_content = json.loads(item.content)
score = item.score
if score >= 5:
type_label = "important"
elif score >= 2:
type_label = "warning"
elif score > 0:
type_label = "info"
else:
type_label = "inverse"
html_type[type_label] += "<label class=\"label label-{}\">{}</label> -> <b>{}</b><pre>{}</pre>".format(
type_label,
escape(decoded_content["type"]),
escape(decoded_content["keyword"]),
escape(decoded_content["description"])
)
elif item.name == 'macros':
decoded_content = json.loads(item.content)
html += "<label class=\"label label-info\">Source</label> : <b>{}</b><pre>{}</pre>".format(escape(decoded_content['vba_filename']),
escape(decoded_content['code']))
else:
html += "LAMA PARSE ERROR"
html += html_type['important']
html += html_type['warning']
html += html_type['info']
html += html_type['inverse']
html += "</div>"
return html
评论列表
文章目录