Skip to content

Commit

Permalink
feat(github): add summary message in github_failed_only output (#6131)
Browse files Browse the repository at this point in the history
* add summary message in github_output

* fix failing checks and add some formating
  • Loading branch information
sourava01 authored May 5, 2024
1 parent 6cc0665 commit 4a1fc23
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions checkov/common/output/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,20 +367,30 @@ def print_failed_github_md(self, use_bc_ids: bool = False) -> str:
result.append(
[
record.get_output_id(use_bc_ids),
record.file_path,
record.resource,
record.check_name,
record.guideline,
record.resource,
f"[Link]({record.guideline})",
record.file_path,
]
)
if result:
summary = self.get_summary()
if self.parsing_errors:
message = "Passed Checks: {}, Failed Checks: {}, Skipped Checks: {}, Parsing Errors: {}\n\n".format(
summary["passed"],
summary["failed"],
summary["skipped"],
summary["parsing_errors"],
)
else:
message = f"```\nPassed Checks: {summary['passed']}, Failed Checks: {summary['failed']}, Skipped Checks: {summary['skipped']}\n```\n\n"

table = tabulate(
result,
headers=["check_id", "file", "resource", "check_name", "guideline"],
headers=["Check ID", "Check Name", "Resource", "Guideline", "File"],
tablefmt="github",
showindex=True,
)
output_data = f"### {self.check_type} scan results:\n\n{table}\n\n---\n"
output_data = f"### {self.check_type.replace('_', ' ').title()} Scan Results:\n\n{message}{table}\n\n---\n"
return output_data
else:
return "\n\n---\n\n"
Expand Down

0 comments on commit 4a1fc23

Please sign in to comment.