244 lines
13 KiB
Plaintext
244 lines
13 KiB
Plaintext
#import "/visual/elements.typ": diag-progress-bar as progress-bar
|
||
|
||
#let get(dict, key, default) = if key in dict and dict.at(key) != none { dict.at(key) } else { default }
|
||
#import "/visual/elements.typ": diag-color as color, diag-ink as ink, diag-muted as muted, diag-accent as accent, diag-line-color as line-color, diag-soft as soft, diag-severity-color as severity-color, diag-badge as badge, diag-heading as heading, diag-part-title as part-title, diag-panel as panel, diag-metric as metric
|
||
|
||
#let header(theme, data, logo) = {
|
||
grid(columns: (1fr, auto), align: (left, right + horizon),
|
||
text(size: 7.5pt, weight: "bold", fill: muted(theme))[
|
||
Beffroi — Windows diagnostics
|
||
],
|
||
image(logo, height: 8mm, fit: "contain"),
|
||
)
|
||
v(3pt)
|
||
line(length: 100%, stroke: .5pt + line-color(theme))
|
||
}
|
||
|
||
#let footer(theme, data) = grid(
|
||
columns: (1fr, auto), align: (left, right),
|
||
text(size: 7pt, fill: muted(theme))[#get(data, "computer", "Unknown") · #get(data, "generated", "Unknown")],
|
||
text(size: 7pt, fill: muted(theme))[Page #context counter(page).display()],
|
||
)
|
||
|
||
#import "/visual/elements.typ": diag-short-text as short-text, diag-finding-target as finding-target, diag-finding-card as finding-card, diag-evidence as evidence
|
||
|
||
#let diagnostics-model(data: (:), author: "", theme: (:), logo: "/assets/beffroi.png", body) = {
|
||
set page(
|
||
paper: "a4", margin: (top: 18mm, bottom: 17mm, left: 18mm, right: 18mm),
|
||
header: context header(theme, data, logo), footer: context footer(theme, data),
|
||
)
|
||
set text(font: get(theme, "font", "DejaVu Sans"), size: 9pt, fill: ink(theme), lang: "en")
|
||
set par(leading: .55em, spacing: .5em)
|
||
|
||
let findings = get(data, "findings", ())
|
||
let priority-findings = findings.filter(item => {
|
||
let title = get(item, "title", "")
|
||
title.contains("System-file") or title.contains("Firewall")
|
||
})
|
||
priority-findings += findings.filter(item => {
|
||
let title = get(item, "title", "")
|
||
not title.contains("System-file") and not title.contains("Firewall")
|
||
})
|
||
let counts = get(data, "issue_counts", (:))
|
||
let critical = get(counts, "critical", 0)
|
||
let warnings = get(counts, "warning", 0)
|
||
let system = get(data, "system", (:))
|
||
let ram-total = get(system, "ram_total_gb", 0)
|
||
let ram-free = get(system, "ram_free_gb", 0)
|
||
let disks = get(data, "disk_free", ())
|
||
let health-score = get(data, "health_score", 0)
|
||
let analysis-confidence = get(data, "analysis_confidence", 50)
|
||
let assessment-tone = if critical > 0 { color(theme, "critical") } else if warnings > 0 { color(theme, "warning") } else { color(theme, "success") }
|
||
let health-tone = if get(data, "collection_incomplete", false) { color(theme, "warning") } else if health-score < 50 { color(theme, "critical") } else if health-score < 75 { color(theme, "warning") } else { color(theme, "success") }
|
||
|
||
// Page 1: deliberately short and decision-oriented.
|
||
text(size: 7.5pt, weight: "bold", fill: muted(theme))[SECTION 01 · EXECUTIVE OVERVIEW]
|
||
v(3pt)
|
||
block(below: 8pt)[
|
||
#text(size: 22pt, weight: "bold", fill: accent(theme))[Windows diagnostic assessment]
|
||
#v(3pt)
|
||
#text(size: 10.5pt, fill: muted(theme))[
|
||
#get(data, "computer", "Unknown computer") · #get(data, "mode", "Unknown") collection · Administrator: #get(data, "administrator", "Unknown")
|
||
]
|
||
]
|
||
|
||
panel(theme, stroke: assessment-tone, fill: assessment-tone.lighten(92%))[
|
||
#text(size: 8pt, weight: "bold", fill: assessment-tone)[OVERALL ASSESSMENT]
|
||
#v(3pt)
|
||
#text(size: 17pt, weight: "bold", fill: assessment-tone)[#get(data, "health", "Unknown")]
|
||
#v(3pt)
|
||
#text(size: 8.5pt)[Generated #get(data, "generated", "Unknown") · Reviewed by #author]
|
||
]
|
||
|
||
v(7pt)
|
||
grid(columns: (1fr, 1fr, 1fr, 1fr), gutter: 5pt,
|
||
metric(theme, "Critical", str(critical), tone: color(theme, "critical")),
|
||
metric(theme, "Warnings", str(warnings), tone: color(theme, "warning")),
|
||
metric(theme, "RAM maximum", str(ram-total) + " GB"),
|
||
metric(theme, "Analysis confidence", str(analysis-confidence) + "%"),
|
||
)
|
||
|
||
v(5pt)
|
||
if get(data, "collection_incomplete", false) {
|
||
text(size: 8pt, weight: "bold", fill: color(theme, "warning"))[Collection is partial. The score covers observed signals only; unavailable checks cannot establish health. Confidence is capped at 50%.]
|
||
}
|
||
v(7pt)
|
||
panel(theme, stroke: health-tone)[
|
||
#grid(columns: (1fr, auto),
|
||
[#text(size: 8pt, weight: "bold", fill: ink(theme))[#if get(data, "collection_incomplete", false) { [OBSERVED SIGNAL SCORE · PARTIAL COLLECTION] } else { [HEALTH ANALYSIS] }]],
|
||
[#text(size: 15pt, weight: "bold", fill: health-tone)[#health-score / 100]],
|
||
)
|
||
#v(4pt)
|
||
#block(width: 100%, height: 7pt, radius: 3.5pt, fill: line-color(theme))[
|
||
#block(width: health-score * 1%, height: 100%, radius: 3.5pt, fill: health-tone)
|
||
]
|
||
#v(3pt)
|
||
#text(size: 7pt, fill: muted(theme))[Heuristic score: 100 − 8 per critical − 2 per warning − 1 per unanalysed signal, with approved age fading. Analysis confidence: #analysis-confidence%. Neither value is a failure probability.]
|
||
]
|
||
|
||
heading(theme, "Priority findings")
|
||
if findings.len() == 0 {
|
||
panel(theme)[No actionable exceptions were detected. This is not proof that the system is fault-free.]
|
||
} else {
|
||
for finding in priority-findings.slice(0, calc.min(4, priority-findings.len())) {
|
||
let finding-index = findings.position(item => item == finding)
|
||
finding-card(theme, finding, show-remediation: false, link-index: finding-index)
|
||
}
|
||
}
|
||
|
||
if disks.len() > 0 {
|
||
heading(theme, "Storage headroom")
|
||
block(width: 100%, inset: 7pt, radius: 3pt, fill: soft(theme), stroke: .5pt + line-color(theme))[
|
||
#for disk in disks.slice(0, calc.min(4, disks.len())) {
|
||
let free-percent = get(disk, "free_percent", 0)
|
||
let disk-tone = if free-percent < 10 { color(theme, "critical") } else if free-percent < 20 { color(theme, "warning") } else { color(theme, "success") }
|
||
grid(columns: (15mm, 1fr, 34mm), gutter: 5pt, align: (left + horizon, left + horizon, right + horizon),
|
||
text(size: 8pt, weight: "bold")[#get(disk, "drive", "Disk")],
|
||
progress-bar(free-percent, width: 100%, height: 7pt, show-value: false, color: disk-tone, background: line-color(theme), theme: (background: soft(theme))),
|
||
text(size: 7.5pt, fill: muted(theme))[#str(get(disk, "free_gb", 0)) GB · #str(free-percent)% free],
|
||
)
|
||
v(3pt)
|
||
}
|
||
#text(size: 7pt, fill: muted(theme))[Free capacity is shown rather than used capacity; low headroom is the actionable condition.]
|
||
]
|
||
}
|
||
|
||
pagebreak()
|
||
|
||
part-title(theme, "02", "Findings requiring attention", description: "Actionable exceptions and the event evidence that supports them.")
|
||
heading(theme, "Resolution plan")
|
||
for (index, finding) in findings.enumerate() { finding-card(theme, finding, target-index: index) }
|
||
|
||
pagebreak()
|
||
heading(theme, "Correlated event evidence")
|
||
[Requested history: #get(get(data, "parameters", (:)), "event_log_days", 7) days; configured maximum: #get(get(data, "parameters", (:)), "max_event_errors", 100) per log. Returned Windows levels: #get(data, "event_counts", (:)).pairs().map(pair => pair.at(0) + ": " + str(pair.at(1))).join(", "). Counts describe captured records; see coverage for truncation and unavailable logs.]
|
||
v(5pt)
|
||
let event-groups = get(data, "event_groups", ())
|
||
let contextual = event-groups.filter(event => get(event, "severity", "info") == "info")
|
||
if contextual.len() > 0 {
|
||
text(size: 8pt)[Contextual events are summarized below; full messages remain in the JSON.]
|
||
table(columns: (1fr, auto, auto, 1.4fr), inset: 3pt, stroke: .3pt + line-color(theme),
|
||
table.header([Provider], [ID], [Count], [Interpretation]),
|
||
..contextual.map(event => ([#event.provider], [#event.id], [#str(event.count)], [#event.rationale])).flatten(),
|
||
)
|
||
v(6pt)
|
||
}
|
||
[Actionable groups show one representative message (up to 600 characters). All occurrence counts and latest timestamps are retained; other message variants remain in source JSON. Reliability history supplements events missing from the bounded logs.]
|
||
v(4pt)
|
||
for event in event-groups.filter(event => get(event, "severity", "info") != "info") {
|
||
let tone = severity-color(theme, get(event, "severity", "info"))
|
||
block(width: 100%, breakable: true, below: 5pt, inset: 6pt, fill: tone.lighten(95%), stroke: (left: 2.5pt + tone, top: .4pt + line-color(theme), right: .4pt + line-color(theme), bottom: .4pt + line-color(theme)), radius: 2pt)[
|
||
#grid(columns: (1fr, auto), gutter: 5pt,
|
||
[*#get(event, "provider", "Unknown")* · Event #get(event, "id", "?")],
|
||
[#badge(get(event, "severity", "info"), tone) #h(3pt) #badge(str(get(event, "count", 1)) + "×", tone)],
|
||
)
|
||
#v(2pt)
|
||
#text(size: 8pt)[#short-text(get(event, "messages", (get(event, "message", ""),)).first(), limit: 600)]
|
||
#if get(event, "rationale", "") != "" { v(2pt); text(size: 7.5pt, style: "italic", fill: tone)[#get(event, "rationale", "")] }
|
||
#v(1pt)
|
||
#text(size: 7pt, fill: muted(theme))[Log: #get(event, "log", "Unknown") · Windows level: #str(get(event, "level", "Unknown")) (#get(event, "level_display", "Unknown")) · Latest captured: #get(event, "display_time", get(event, "time", "Unknown"))]
|
||
]
|
||
}
|
||
|
||
pagebreak()
|
||
|
||
part-title(theme, "03", "Technical evidence", description: "System context, selected source evidence, and an audit of collector coverage.")
|
||
|
||
heading(theme, "System profile")
|
||
table(
|
||
columns: (32mm, 1fr, 32mm, 1fr), inset: 5pt, stroke: .4pt + line-color(theme),
|
||
fill: (x, y) => if calc.rem(y, 2) == 0 { soft(theme) } else { none },
|
||
[Computer], [#get(data, "computer", "Unknown")], [Administrator], [#get(data, "administrator", "Unknown")],
|
||
[Operating system], [#get(system, "os", "Unknown")], [Build], [#get(system, "build", "Unknown")],
|
||
[CPU], [#get(system, "cpu", "Unknown")], [Cores / threads], [#get(system, "cores", "?") / #get(system, "threads", "?")],
|
||
[Memory], [#str(ram-total) GB total], [Free at capture], [#str(ram-free) GB],
|
||
)
|
||
|
||
if disks.len() > 0 {
|
||
heading(theme, "Storage capacity")
|
||
for disk in disks {
|
||
let used = 100 - get(disk, "free_percent", 0)
|
||
panel(theme)[
|
||
#grid(columns: (1fr, auto), [*#get(disk, "drive", "Disk")*], [#str(get(disk, "free_gb", 0)) GB free of #str(get(disk, "size_gb", 0)) GB])
|
||
#v(4pt)
|
||
#block(width: 100%, height: 5pt, radius: 2.5pt, fill: line-color(theme))[
|
||
#block(width: used * 1%, height: 100%, radius: 2.5pt, fill: if used > 90 { color(theme, "critical") } else if used > 80 { color(theme, "warning") } else { accent(theme) })
|
||
]
|
||
]
|
||
v(4pt)
|
||
}
|
||
}
|
||
|
||
heading(theme, "Inventory summary")
|
||
let inventory = get(data, "inventory", ())
|
||
table(
|
||
columns: (1fr, 22mm), inset: 4pt, stroke: .4pt + line-color(theme),
|
||
table.header([Category], [Count]),
|
||
..inventory.map(item => ([#get(item, "label", "")], [#get(item, "count", 0)])).flatten(),
|
||
)
|
||
|
||
heading(theme, "Selected source evidence")
|
||
[Selected evidence shows up to three records and 1,200 characters per expanded section. Routine service/driver inventories, successful native command dumps and update successes are summarized. Complete data remains in the source JSON.]
|
||
v(5pt)
|
||
for item in get(data, "excerpts", ()) { evidence(theme, item) }
|
||
|
||
heading(theme, "Known-issue watchlist")
|
||
let watchlist = get(data, "watchlist", (:))
|
||
text(size: 8pt)[Reviewed #get(watchlist, "reviewed", "Unknown"). Matches raise review warnings; they do not establish crash causation. This curated list is not an exhaustive vulnerability scan. Advisory warnings add no score penalty; observed failures retain their event penalties.]
|
||
v(3pt)
|
||
text(size: 8pt, fill: accent(theme))[#link(get(watchlist, "driver_list_url", ""))[Microsoft vulnerable driver list ↗]]
|
||
v(4pt)
|
||
table(columns: (20mm, 1fr, 27mm), inset: 4pt, stroke: .3pt + line-color(theme),
|
||
table.header([Type], [Known issue], [Reference]),
|
||
..get(watchlist, "entries", ()).map(entry => (
|
||
[#entry.category],
|
||
[#metadata("watchlist") #label("watchlist-" + entry.id) #entry.title],
|
||
[#link(get(entry, "list_url", entry.reference_url))[Source ↗]],
|
||
)).flatten(),
|
||
)
|
||
|
||
pagebreak()
|
||
heading(theme, "Analysis coverage")
|
||
[Every supplied WinDiagnostics JSON section is accounted for. This table records how each section contributed without reproducing low-value bulk data.]
|
||
v(4pt)
|
||
table(
|
||
columns: (1fr, 1fr, 15mm), inset: 4pt, stroke: none,
|
||
fill: (x, y) => if y == 0 { soft(theme) } else {
|
||
let item = get(data, "coverage", ()).at(y - 1, default: (:))
|
||
severity-color(theme, get(item, "severity", "info")).lighten(92%)
|
||
},
|
||
table.header([Collector section], [Treatment], [Records]),
|
||
..get(data, "coverage", ()).map(item => (
|
||
[#get(item, "section", "")], [#get(item, "use", "")], [#if get(item, "records", 0) == "Unavailable" { [—] } else { get(item, "records", 0) }],
|
||
)).flatten(),
|
||
)
|
||
|
||
v(3pt)
|
||
text(size: 7pt, fill: muted(theme))[— = unavailable record count.]
|
||
|
||
v(8pt)
|
||
text(size: 7pt, fill: muted(theme))[
|
||
Source: #get(data, "source", "Unknown"). This synthesis is heuristic: it prioritizes exceptions and suppresses routine inventory, but does not replace targeted diagnosis.
|
||
]
|
||
}
|