import html import json import sys STYLE = """""" def rows(results, state): for c in results: note = c["check_result"].get("suppress_comment", "") if state == "SKIPPED" else "" yield ( f"{state}{c['check_id']}" f"{html.escape(c['check_name'])}{html.escape(c['resource'])}" f"{c['file_line_range'][0]}-{c['file_line_range'][1]}{html.escape(note)}" ) report_json, out, title = sys.argv[1:4] d = json.load(open(report_json, encoding="utf-8")) s, r = d["summary"], d["results"] body = list(rows(r.get("failed_checks", []), "FAILED")) + list(rows(r.get("skipped_checks", []), "SKIPPED")) page = ( f"Checkov 결과{STYLE}

{html.escape(title)}

" f"
통과 {s['passed']}
실패 {s['failed']}
" f"
예외 {s['skipped']}
" f"{''.join(body)}
상태검사 ID검사 내용리소스줄예외 사유
" ) open(out, "w", encoding="utf-8").write(page)