From bf0ac5e33bdc4f254295a0b85e639432f4eb63c5 Mon Sep 17 00:00:00 2001 From: oval Date: Tue, 7 Jul 2026 16:57:38 +0000 Subject: [PATCH] Add reports/report.gohtml --- reports/report.gohtml | 62 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 reports/report.gohtml diff --git a/reports/report.gohtml b/reports/report.gohtml new file mode 100644 index 0000000..ed03da7 --- /dev/null +++ b/reports/report.gohtml @@ -0,0 +1,62 @@ +{{- /* +report.gohtml — IEC 62443-3-3 SL2 Compliance Report Template + +An external Go template rendered by reports/render.go. Receives the full +JSON document as an untyped map[string]any. Access fields via (index . "key"). + +Template functions (registered by render.go): + passIcon v → "✅ PASS" / "❌ FAIL" / "❓ MANUAL" + severityIcon s → 🔴/🟠/🟡/🟢/⚪ + title s → "Hello World" (capitalizes words) + divf a b → a / b * 100.0 (percentage) + add a b / sub a b → integer arithmetic + +To customize: copy this file, modify, run: + go run reports/render.go reports/*.json my-custom.gohtml +*/ -}} +╔══════════════════════════════════════════════════════════════════════════╗ +║ IEC 62443-3-3 SECURITY LEVEL 2 — COMPLIANCE REPORT ║ +╠══════════════════════════════════════════════════════════════════════════╣ +║ Target: {{ (index .meta "target") }} +║ Standard: {{ (index .meta "standard") }} +║ Level: {{ (index .meta "security_level") }} +║ Timestamp: {{ (index .meta "timestamp") }} +║ Executed by: {{ (index .meta "executed_by") }} +╠══════════════════════════════════════════════════════════════════════════╣ +║ EXECUTIVE SUMMARY ║ +╠══════════════════════════════════════════════════════════════════════════╣ +║ ║ +║ TOTAL PASSED FAILED REVIEW COMPLIANCE ║ +║ ───── ────── ────── ────── ────────── ║ +║ {{ printf "%-8d" (index .summary "total") }} {{ printf "%-9d" (index .summary "passed") }} {{ printf "%-9d" (index .summary "failed") }} {{ printf "%-9d" (index .summary "skipped") }} {{ if gt (index .summary "total") 0 }}{{ printf "%.1f%%" (divf (index .summary "passed") (index .summary "total")) }}{{ else }}N/A{{ end }} +║ ║ +╠══════════════════════════════════════════════════════════════════════════╣ +║ RESULTS BY REQUIREMENT ║ +╠══════════════════════════════════════════════════════════════════════════╣ +║ ║ +{{- $results := index . "results" }} +{{- range $i, $r := $results }} +║ {{ severityIcon (index $r "severity") }} [{{ index $r "test_id" }}] {{ passIcon (index $r "passed") }} {{ index $r "description" }} +║ Requirement: {{ index $r "requirement" }} +║ Expected: {{ index $r "expected" }} +║ Actual: {{ index $r "actual" }} +{{- if not (index $r "passed") }} +║ Fix: {{ index $r "remediation" }} +{{- end }} +║ ║ +{{- end }} +╠══════════════════════════════════════════════════════════════════════════╣ +║ FAILURE DETAIL ║ +╠══════════════════════════════════════════════════════════════════════════╣ +{{- $failures := index . "failures" }} +{{- if $failures }} +{{- range $i, $f := $failures }} +║ ❌ {{ index $f "test_id" }} — {{ index $f "description" }} +║ Severity: {{ index $f "severity" | title }} +║ Remediation: {{ index $f "remediation" }} +║ ║ +{{- end }} +{{- else }} +║ ✅ ALL CONTROLS PASSED ║ +{{- end }} +╚══════════════════════════════════════════════════════════════════════════╝