check_sys/report.py
2023-06-07 16:49:12 +02:00

42 lines
1.3 KiB
Python

#!/usr/bin/env python3
from datetime import datetime
def generateHtmlReport(data):
today = datetime.now().isoformat()[0:10].replace("-", "_")
html = "<!doctype html>" \
"<html>" \
"<head>" \
"</head>" \
"<body>" \
f"<h1>Reports of {today}</h1>"
body = str()
# For sysctl
for entry in data['sysctl']:
body += f"<h2>Sysctl</h2>"
# For file
body += f"<h3>File</h3>"
for f in data['sysctl']['file']:
body += f"<h4>{data['sysctl']['file']['filename']}</h4>"
for vul in data['sysctl']['file']['sysctl']:
#print(data['sysctl']['file']['sysctl'][vul])
body += f"<h5>{vul}</h5>"
body += f"<p>"
body += f"Results:<br />"
#for result in data['sysctl']['file']['sysctl'][vul]:
# print(result)
# body += f"Line: {result['lineNumber']}<br />"
# body += f"Line: {result['line']}<br />"
# body += f"Level: {result['level']}<br />"
# body += f"Description: {result['description']}<br /><br />"
#body += f"</p>"
html += body
#print(body)
html += "</body></html>"
with open(f"reports/reports_{today}.html", "w") as f:
f.write(html)