Add weekly organization security reports
This commit is contained in:
@@ -95,6 +95,45 @@ def device(machine_name):
|
||||
return render_template("device.html", report=report, payload=payload, payload_pretty=json.dumps(payload, indent=2, ensure_ascii=False))
|
||||
|
||||
|
||||
@app.get("/reports")
|
||||
@requires_auth
|
||||
def reports():
|
||||
with db_connection() as connection, connection.cursor() as cursor:
|
||||
cursor.execute(
|
||||
"""
|
||||
SELECT id, organization_name, period_start_utc, period_end_utc,
|
||||
generated_at, device_count, warning_count, critical_count,
|
||||
total_events
|
||||
FROM ocsentinel.weekly_organization_report
|
||||
ORDER BY period_end_utc DESC, organization_name
|
||||
"""
|
||||
)
|
||||
weekly_reports = cursor.fetchall()
|
||||
|
||||
return render_template("reports.html", reports=weekly_reports)
|
||||
|
||||
|
||||
@app.get("/reports/<int:report_id>")
|
||||
@requires_auth
|
||||
def weekly_report(report_id):
|
||||
with db_connection() as connection, connection.cursor() as cursor:
|
||||
cursor.execute(
|
||||
"""
|
||||
SELECT organization_name, period_start_utc, period_end_utc,
|
||||
generated_at, report_html
|
||||
FROM ocsentinel.weekly_organization_report
|
||||
WHERE id = %s
|
||||
""",
|
||||
(report_id,),
|
||||
)
|
||||
report = cursor.fetchone()
|
||||
|
||||
if report is None:
|
||||
abort(404)
|
||||
|
||||
return render_template("weekly_report.html", report=report)
|
||||
|
||||
|
||||
@app.get("/healthz")
|
||||
def healthz():
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user