in utils/comment-github-pr.py [0:0]
def markdownify_gcc_report(report_file, summary=False, report_zero=False):
"""This method assumes this script is invoked in a github workflow"""
try:
with open(report_file) as report:
findings = report.readlines()
except Exception as e:
log.error("Failed to load report from %s, failed with %e", report_file, e)
nr_findings = len(findings)
files = set([x.split(":")[0] for x in findings])
markdown_message = ""
# Do we need to report findings?
if nr_findings > 0 or report_zero:
# Write a basic summary of the findings
markdown_message = "One Line Scan: **reported {} findings** in {} files".format(
nr_findings, len(files)
)
# Add task list with all findings
if not summary:
markdown_message += "\n\n"
for finding in findings:
markdown_message += "- [ ] {}\n".format(finding.rstrip())
markdown_message += "\n\n"
return markdown_message, 0