Skip to content

Commit b6c5e11

Browse files
bluesentinelsecMichael Long
andauthored
Omit Dockerfile table on no vulns (#94)
Co-authored-by: Michael Long <[email protected]>
1 parent 9d3b153 commit b6c5e11

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

entrypoint/entrypoint/dockerfile.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,9 @@ def get_markdown_header() -> str:
263263
s += "|---|---|---|---|---|\n"
264264
return s
265265

266+
def get_markdown_header_no_vulns() -> str:
267+
s = "## Dockerfile Findings\n"
268+
return s
266269

267270
def get_dockerfile_vulns(inspector_scan_path):
268271
vuln_objects = []
@@ -326,14 +329,16 @@ def write_dockerfile_report_csv(inspector_scan_path, dst_file):
326329
def write_dockerfile_report_md(inspector_scan_path, dst_file):
327330
dockerfile_vulns = get_dockerfile_vulns(inspector_scan_path)
328331

329-
markdown_report = get_markdown_header()
330-
for vuln in dockerfile_vulns:
331-
row = vuln_to_markdown_row(vuln)
332-
markdown_report += row
333-
332+
markdown_report = ""
334333
if len(dockerfile_vulns) == 0:
334+
markdown_report = get_markdown_header_no_vulns()
335335
row = "\n\n:green_circle: Amazon Inspector scanned for security issues in Dockerfiles and no issues were found."
336336
markdown_report += row
337+
else:
338+
markdown_report = get_markdown_header()
339+
for vuln in dockerfile_vulns:
340+
row = vuln_to_markdown_row(vuln)
341+
markdown_report += row
337342

338343
logging.info(f"writing Dockerfile vulnerability markdown report to: {dst_file}")
339344
with open(dst_file, "w") as f:

0 commit comments

Comments
 (0)