#let report-file = sys.inputs.at("report") #let report-format = sys.inputs.at("format") #let report = if report-format == "json" { json(report-file) } else { yaml(report-file) } #let get(data, key, default: none) = data.at(key, default: default) #let branding = get(report, "branding", default: (:)) #let theme = get(branding, "theme", default: (:)) #let color(key, fallback) = rgb(str(get(theme, key, default: fallback))) #let ink = color("ink", "#22262b") #let muted = color("muted", "#66707a") #let line-color = color("line", "#d7dce1") #let soft = color("paper_soft", "#f5f7f8") #let accent = color("accent", "#34495e") #let severity-color(value) = if value == "critical" { color("critical", "#7a3030") } else if value in ("warning", "high", "medium") { color("warning", "#8a671c") } else if value in ("ok", "success") { color("success", "#356344") } else { color("info", "#385f7a") } #let as-text(value) = str(value) #let heading(title) = block(above: 12pt, below: 5pt)[ #text(size: 13pt, weight: "bold", fill: accent)[#as-text(title)] #line(length: 100%, stroke: 0.6pt + line-color) ] #let badge(value) = box(inset: (x: 5pt, y: 2pt), radius: 2pt, fill: severity-color(str(value)).lighten(85%), stroke: 0.5pt + severity-color(str(value)))[ #text(size: 7.5pt, weight: "bold", fill: severity-color(str(value)))[#as-text(value)] ] #let callout(body, kind: "info", title: none) = block(width: 100%, inset: 8pt, fill: severity-color(kind).lighten(92%), stroke: (left: 2pt + severity-color(kind)))[ #if title != none { text(weight: "bold", fill: severity-color(kind))[#as-text(title)]; parbreak() } #body ] #let render-block(item) = { let kind = get(item, "type", default: "text") if kind == "text" { [#as-text(get(item, "text", default: ""))] } else if kind == "bullets" { list(..get(item, "items", default: ()).map(value => [#as-text(value)])) } else if kind == "steps" { enum(..get(item, "items", default: ()).map(value => [#as-text(value)])) } else if kind == "callout" { callout([#as-text(get(item, "text", default: ""))], kind: get(item, "kind", default: "info"), title: get(item, "title", default: none)) } else if kind == "code" { block(width: 100%, inset: 7pt, fill: soft, stroke: 0.5pt + line-color)[#text(font: get(theme, "mono_font", default: "DejaVu Sans Mono"), size: 8pt)[#as-text(get(item, "text", default: ""))]] } else if kind == "subsection" { block(above: 5pt, below: 3pt)[#text(weight: "bold", fill: ink)[#as-text(get(item, "title", default: ""))]] for child in get(item, "content", default: ()) { render-block(child); v(3pt) } } } #let logo = get(branding, "logo", default: none) #let organization = get(branding, "organization", default: "Report") #set page(paper: "a4", margin: (top: 20mm, bottom: 18mm, x: 20mm), header: context { grid(columns: (1fr, auto), align: (left, right + horizon), text(size: 7.5pt, weight: "bold", fill: muted)[#as-text(organization)], if logo != none { image(logo, height: 8mm, fit: "contain") }) v(3pt); line(length: 100%, stroke: 0.5pt + line-color) }, footer: context grid(columns: (1fr, auto), text(size: 7pt, fill: muted)[#if "id" in report { [Report #as-text(report.id)] }], text(size: 7pt, fill: muted)[Page #counter(page).display()])) #set text(font: get(theme, "font", default: "DejaVu Sans"), size: 9.5pt, fill: ink) #set par(leading: 0.58em, spacing: 0.55em) #text(size: 22pt, weight: "bold", fill: accent)[#as-text(report.title)] #if "subtitle" in report { v(3pt); text(size: 11pt, fill: muted)[#as-text(report.subtitle)] } #if "report_type" in report or "status" in report or "severity" in report { v(7pt) for value in (get(report, "report_type"), get(report, "status"), get(report, "severity")) { if value != none { badge(value); h(4pt) } } } #v(10pt) #block(width: 100%, inset: 8pt, fill: soft, stroke: 0.5pt + line-color)[ #grid(columns: (1fr, 1fr), row-gutter: 5pt, column-gutter: 10pt, ..report.metadata.pairs().map(pair => [#text(size: 7.5pt, fill: muted)[#pair.at(0)]\ #as-text(pair.at(1))])) ] #if "summary" in report { heading("Executive summary"); callout([#as-text(report.summary)]) } #if "timeline" in report and report.timeline.len() > 0 { heading("Timeline") for entry in report.timeline { block(below: 5pt)[#text(weight: "bold", fill: accent)[#as-text(entry.time)] #h(6pt)#as-text(entry.event)#if "notes" in entry { [ — #as-text(entry.notes)] }] } } #if "findings" in report and report.findings.len() > 0 { heading("Findings") for finding in report.findings { block(width: 100%, inset: 8pt, below: 6pt, stroke: 0.5pt + line-color, radius: 2pt)[ #text(weight: "bold")[#as-text(finding.title)] #if "severity" in finding { h(5pt); badge(finding.severity) } #if "evidence" in finding { parbreak(); text(size: 8pt, fill: muted)[Evidence]; parbreak(); as-text(finding.evidence) } #if "assessment" in finding { parbreak(); text(size: 8pt, fill: muted)[Assessment]; parbreak(); as-text(finding.assessment) } ] } } #for section in get(report, "sections", default: ()) { heading(section.title) for item in section.content { render-block(item); v(4pt) } } #if "actions" in report and report.actions.len() > 0 { heading(get(report, "actions_title", default: "Action plan")) for action in report.actions { block(below: 5pt)[#text(weight: "bold")[#as-text(action.title)] #if "status" in action { h(5pt); badge(action.status) } #if "text" in action { parbreak(); as-text(action.text) } #for command in get(action, "commands", default: ()) { parbreak(); render-block((type: "code", text: command)) }] } } #if "closing" in report { heading("Current state"); callout([#as-text(report.closing)], title: "Stopping point") } #for section in get(report, "appendices", default: ()) { pagebreak(weak: true); heading(section.title) for item in section.content { render-block(item); v(4pt) } }