From e08a71fad496ec2f3e09c8cd9ead3f52415f04c9 Mon Sep 17 00:00:00 2001 From: Dandaedre Date: Mon, 14 Sep 2026 19:00:23 +0200 Subject: [PATCH] Migrate diagnostics to JSON and classify crash evidence --- README.md | 4 +- diagnostics-model.typ | 8 +- diagnostics-normalize.typ | 753 ++++++++++++++++++-------- diagnostics-rules.yaml | 18 + diagnostics.typ | 26 +- docs/diagnostics.md | 70 ++- render-diagnostics.sh | 22 +- tools/check-diagnostics.typ | 133 +++-- tools/fixtures/windiagnostics-v1.json | 186 +++++++ 9 files changed, 905 insertions(+), 315 deletions(-) create mode 100644 tools/fixtures/windiagnostics-v1.json diff --git a/README.md b/README.md index 69cedb9..7f00129 100644 --- a/README.md +++ b/README.md @@ -57,10 +57,10 @@ Compilation stops with an actionable error if `metadata.Date` or Convert a Full WinDiagnostics text dump into a concise, exception-focused PDF: ```bash -./render-diagnostics.sh diagnostics/windows_system_report_PC.txt "Your Name" cic +./render-diagnostics.sh diagnostics/windows_system_report_PC.json "Your Name" cic ``` -The theme argument is optional and defaults to `default`. Render every `.txt` +The theme argument is optional and defaults to `default`. Render every `.json` dump under `diagnostics/` recursively with: ```bash diff --git a/diagnostics-model.typ b/diagnostics-model.typ index 117d5c4..09e0c0b 100644 --- a/diagnostics-model.typ +++ b/diagnostics-model.typ @@ -248,7 +248,7 @@ #text(size: 8pt)[#get(event, "message", "")] #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))[Latest captured: #get(event, "time", "Unknown")] + #text(size: 7pt, fill: muted(theme))[Latest captured: #get(event, "display_time", get(event, "time", "Unknown"))] ] } @@ -296,7 +296,7 @@ pagebreak() heading(theme, "Analysis coverage") - [Every WinDiagnostics section was reviewed. This table records how each section contributed without reproducing low-value bulk data.] + [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, @@ -304,9 +304,9 @@ let item = get(data, "coverage", ()).at(y - 1, default: (:)) severity-color(theme, get(item, "severity", "info")).lighten(92%) }, - table.header([Collector section], [Treatment], [Lines]), + table.header([Collector section], [Treatment], [Records]), ..get(data, "coverage", ()).map(item => ( - [#get(item, "section", "")], [#get(item, "use", "")], [#get(item, "lines", 0)], + [#get(item, "section", "")], [#get(item, "use", "")], [#get(item, "records", 0)], )).flatten(), ) diff --git a/diagnostics-normalize.typ b/diagnostics-normalize.typ index bd2c782..ddf0395 100644 --- a/diagnostics-normalize.typ +++ b/diagnostics-normalize.typ @@ -1,17 +1,53 @@ -// Pure-Typst normalizer for WinDiagnostics text transcripts. +// Pure-Typst normalizer for WinDiagnostics schema_version 1 JSON reports. +// +// The collector now emits structured JSON. This file intentionally does not +// reconstruct tables or parse presentation text. It only performs reporting +// work: classification, correlation, scoring, evidence selection and shaping +// the collector schema for diagnostics-model.typ. -#let get(dict, key, default) = if key in dict { dict.at(key) } else { default } - -#let capture(text, pattern, default: "Unknown") = { - let found = text.match(regex(pattern)) - if found == none { default } else { found.captures.at(0) } +// The legacy converter used snake_case for CIM fields; native JSON preserves case. +#let get(dict, key, default) = { + if type(dict) != dictionary { default } else { + let matched = if key in dict { key } else { + dict.keys().find(candidate => lower(candidate.replace("_", "")) == lower(key.replace("_", ""))) + } + if matched == none or dict.at(matched) == none { default } else { dict.at(matched) } + } } +#let enabled(value) = value == true or value == 1 +#let legacy-incomplete(report, name) = { + let value = get(get(report, "sections", (:)), name, (:)) + get(report, "legacy", none) != none and ( + name == "" or name == "storage" or + get(value, "data", ()).any(item => get(item, "text", none) != none) + ) +} + +#let first(values, default: (:)) = { + if values == none or values.len() == 0 { default } else { values.at(0) } +} + +#let section(report, name) = { + let sections = get(report, "sections", (:)) + get(sections, name, (status: "missing", count: 0, data: (), error: none)) +} + +#let section-data(report, name) = get(section(report, name), "data", ()).filter(item => get(item, "text", none) == none) +#let section-first(report, name) = first(section-data(report, name)) +#let section-count(report, name) = if legacy-incomplete(report, name) { "Unavailable" } else { get(section(report, name), "count", 0) } +#let section-status(report, name) = get(section(report, name), "status", "missing") #let number(value, default: 0.0) = { - let found = str(value).replace(",", ".").match(regex("-?\\d+(?:\\.\\d+)?")) - if found == none { default } else { float(found.text) } + if value == none { default } + else if type(value) == int or type(value) == float { value } + else { + let found = str(value).replace(",", ".").match(regex("-?\\d+(?:\\.\\d+)?")) + if found == none { default } else { float(found.text) } + } } +#let bool-text(value) = if value == true { "Yes" } else if value == false { "No" } else { str(value) } + #let is-leap-year(year) = calc.rem(year, 4) == 0 and (calc.rem(year, 100) != 0 or calc.rem(year, 400) == 0) #let date-index(year, month, day) = { @@ -20,25 +56,60 @@ 365 * completed-year + int(calc.floor(completed-year / 4)) - int(calc.floor(completed-year / 100)) + int(calc.floor(completed-year / 400)) + before-month.at(month - 1) + day + if month > 2 and is-leap-year(year) { 1 } else { 0 } } -#let report-day(value) = { - let found = str(value).match(regex("^(\\d{4})-(\\d{2})-(\\d{2})")) - if found == none { none } else { date-index(int(found.captures.at(0)), int(found.captures.at(1)), int(found.captures.at(2))) } -} - -#let event-day(value, day-first: false) = { - let found = str(value).match(regex("^(\\d{1,2})/(\\d{1,2})/(\\d{4})")) - if found == none { none } else { - let year = int(found.captures.at(2)) - let month = int(found.captures.at(if day-first { 1 } else { 0 })) - let day = int(found.captures.at(if day-first { 0 } else { 1 })) - if month < 1 or month > 12 or day < 1 or day > 31 { none } else { date-index(year, month, day) } +#let datetime-day(value) = { + let text = str(value) + let iso = text.match(regex("^(\\d{4})-(\\d{2})-(\\d{2})")) + if iso != none { + date-index(int(iso.captures.at(0)), int(iso.captures.at(1)), int(iso.captures.at(2))) + } else { + // Windows PowerShell 5.1 may serialize DateTime values as /Date(ms)/. + let ms = text.match(regex("^/Date\\((-?\\d+)")) + if ms == none { none } else { + date-index(1970, 1, 1) + int(calc.floor(float(ms.captures.at(0)) / 86400000)) + } } } -#let fade-weight(rule, event-time, reference-day, day-first: false) = { - if rule == none or not get(rule, "fading", false) or reference-day == none { (factor: 1.0, age_days: none) } else { - let observed-day = event-day(event-time, day-first: day-first) - if observed-day == none { (factor: 1.0, age_days: none) } else { +#let datetime-second(value) = { + let text = str(value) + let day = datetime-day(text) + if day == none { none } else { + let iso-clock = text.match(regex("T(\\d{2}):(\\d{2}):(\\d{2})")) + if iso-clock != none { + let offset = text.match(regex("([+-])(\\d{2}):(\\d{2})$")) + let shift = if offset == none { 0 } else { (if offset.captures.at(0) == "-" { -1 } else { 1 }) * (int(offset.captures.at(1)) * 3600 + int(offset.captures.at(2)) * 60) } + (day - date-index(1970, 1, 1)) * 86400 + int(iso-clock.captures.at(0)) * 3600 + int(iso-clock.captures.at(1)) * 60 + int(iso-clock.captures.at(2)) - shift + } else { + let ms = text.match(regex("^/Date\\((-?\\d+)")) + if ms == none { none } else { int(calc.floor(float(ms.captures.at(0)) / 1000)) } + } + } +} + +// Display absolute event times in UTC; retain raw values for correlation/fading. +#let display-time(value) = { + let raw = str(value) + let seconds = datetime-second(raw) + if seconds == none { raw } else { + let instant = datetime(year: 1970, month: 1, day: 1, hour: 0, minute: 0, second: 0) + duration(seconds: seconds) + instant.display("[year]-[month]-[day] [hour]:[minute]:[second]") + " UTC" + } +} + +#let display-date(value) = { + let text = str(value) + let iso = text.match(regex("^(\\d{4}-\\d{2}-\\d{2})")) + if iso == none { text } else { iso.captures.at(0) } +} + +#let fade-weight(rule, event-time, reference-day) = { + if rule == none or not get(rule, "fading", false) or reference-day == none { + (factor: 1.0, age_days: none) + } else { + let observed-day = datetime-day(event-time) + if observed-day == none { + (factor: 1.0, age_days: none) + } else { let age = calc.max(0, reference-day - observed-day) let starts = get(rule, "fade_after_days", 7) let reaches-half = calc.max(starts + 1, get(rule, "fade_to_half_days", 90)) @@ -48,94 +119,55 @@ } } -#let parse-sections(text) = { - let headings = text.matches(regex("(?m)^--- (.+?) ---[ \\t]*$")) - let sections = (:) - for (index, heading) in headings.enumerate() { - let end = if index + 1 < headings.len() { headings.at(index + 1).start } else { text.len() } - sections.insert(heading.captures.at(0).trim(), text.slice(heading.end, end).trim()) - } - sections -} - -#let field(text, name, default: "Unknown") = capture( - text, - "(?m)^" + name + "[ \\t]*:[ \\t]*(.*?)[ \\t]*$", - default: default, +#let event-rule(rules, event) = get(rules, "event_rules", ()).find( + rule => get(rule, "provider", "") == event.provider and str(get(rule, "id", "")) == event.id, ) -#let section(sections, name) = get(sections, name, "") - -#let useful-lines(text) = text.split(regex("\\r?\\n")).filter(line => line.trim() != "") - -#let table-count(text) = { - let lines = useful-lines(text).filter(line => { - let clean = line.trim() - let keep = clean.match(regex("^[ -]+$")) == none - keep = keep and not clean.ends-with(":") - keep = keep and not clean.starts-with("Name ") - keep = keep and not clean.starts-with("DisplayName ") - keep = keep and not clean.starts-with("DeviceID ") - keep = keep and not clean.starts-with("TaskName ") - keep = keep and not clean.starts-with("HotFixID ") - keep = keep and not clean.starts-with("ProcessName ") - keep = keep and not clean.starts-with("FriendlyName ") - keep = keep and not clean.starts-with("Model ") - keep - }) - lines.len() -} - -#let parse-events(sections) = { - let events = () - for (name, body) in sections.pairs() { - if name.starts-with("RECENT ") and name.contains("ERRORS") { - let chunks = body.split(regex("(?m)^TimeCreated[ \\t]*:[ \\t]*")) - for chunk in chunks { - if chunk.contains("ProviderName") and chunk.contains("Id") { - let message-pos = chunk.position(regex("(?m)^Message[ \\t]*:[ \\t]*")) - let message = if message-pos == none { - "No message" - } else { - chunk.slice(message-pos).replace(regex("(?m)^Message[ \\t]*:[ \\t]*"), "").replace(regex("\\s+"), " ").trim() - } - events.push(( - time: capture(chunk, "^([^\\n]+)", default: "Unknown"), - id: field(chunk, "Id", default: "?"), - provider: field(chunk, "ProviderName"), - message: message, - log: if name.contains("SYSTEM") { "System" } else { "Application" }, - )) - } - } - } - } - events -} - -#let event-rule(rules, event) = { - get(rules, "event_rules", ()).find( - rule => get(rule, "provider", "") == event.provider and get(rule, "id", "") == event.id, - ) +#let capture(text, pattern, default: "Unknown") = { + let found = str(text).match(regex(pattern)) + if found == none { default } else { found.captures.at(0) } } #let event-summary(event) = { - if event.provider == "MsiInstaller" { + if event.provider == "Microsoft-Windows-WER-SystemErrorReporting" and event.id == "1001" and lower(event.message).contains("0x00000133") { + "DPC_WATCHDOG_VIOLATION (0x133): Windows detected excessive time in a DPC/ISR or at elevated interrupt level. Analyze the saved dump to identify the responsible component. " + event.message + } else if event.provider == "MsiInstaller" { let product = capture(event.message, "Product: (.*?) --", default: "Unknown product") let error = capture(event.message, "Error (\\d+)", default: "unknown") - let description = capture(event.message, "-- Error \\d+\\. (.*?)(?:[ \t]+Action[ \t]|$)", default: "Windows Installer did not complete the transaction.") + let description = capture(event.message, "-- Error \\d+\\. (.*?)(?:[ \\t]+Action[ \\t]|$)", default: "Windows Installer did not complete the transaction.") product + " installation failed with MSI error " + error + ". " + description } else if event.provider == "Application Error" and event.id == "1000" { let application = capture(event.message, "(?:Faulting application name|Nom de l’application défaillante|Nom de l'application défaillante) *: ([^,]+)", default: "Unknown application") - let module = capture(event.message, "(?:Faulting module name|Nom du module défaillant) *: ([^,]+)", default: "unknown module") - let exception = capture(event.message, "Exception code: ([^ ]+)", default: "unknown code") + let module = capture(event.message, "(?:Faulting module name|faulting module name|Nom du module défaillant) *: ([^,]+)", default: "unknown module") + let exception = capture(event.message, "(?:Exception code|exception code): ([^ ]+)", default: "unknown code") application + " terminated unexpectedly in " + module + " (exception " + exception + ")." } else { event.message } } -#let group-events(events, rules, reference-day: none, day-first: false) = { +#let raw-events(report) = { + let events = () + for (section-name, log-name) in ( + ("recent_system_errors", "System"), + ("recent_application_errors", "Application"), + ) { + for item in section-data(report, section-name) { + events.push(( + time: str(get(item, "TimeCreated", "Unknown")), + id: str(get(item, "Id", "?")), + provider: str(get(item, "ProviderName", "Unknown")), + message: str(get(item, "Message", "No message")) + if get(report, "legacy", none) != none { + item.pairs().filter(pair => not (pair.at(0) in ("time_created", "id", "provider_name", "message"))).map(pair => " " + pair.at(0).replace("_", " ") + ": " + str(if pair.at(1) == none { "" } else { pair.at(1) })).join("") + } else { "" }, + log: log-name, + )) + } + } + events +} + +#let group-events(events, rules, reference-day: none) = { let groups = () for event in events { let index = groups.position(group => group.provider == event.provider and group.id == event.id) @@ -145,7 +177,7 @@ item.insert("count", 1) item.insert("messages", (item.message,)) let rule = event-rule(rules, event) - let fading = fade-weight(rule, event.time, reference-day, day-first: day-first) + let fading = fade-weight(rule, event.time, reference-day) item.insert("severity", if rule == none { get(rules, "unknown_event_severity", "unanalysed") } else { get(rule, "severity", "unanalysed") }) item.insert("rationale", if rule == none { "FAIL TO ANALYSE — no matching rule in diagnostics-rules.yaml." } else { get(rule, "rationale", "") }) item.insert("remediation", if rule == none { "Add a reviewed provider/ID rule before attempting cleanup." } else { get(rule, "remediation", "") }) @@ -165,6 +197,15 @@ item.messages.push(summary) item.message = item.messages.join(" / ") } + // Keep the latest parseable event timestamp for display/fading context. + let old-time = datetime-second(item.time) + let new-time = datetime-second(event.time) + if new-time != none and (old-time == none or new-time > old-time) { + item.time = event.time + let fading = fade-weight(event-rule(rules, event), event.time, reference-day) + item.weight_factor = fading.factor + item.age_days = fading.age_days + } groups.at(index) = item } } @@ -172,202 +213,440 @@ } // Correlate original records before provider/ID grouping loses timestamps. -#let event-second(value, day-first: false) = { - let day = event-day(value, day-first: day-first) - let clock = str(value).match(regex(" (\\d{1,2}):(\\d{2}):(\\d{2})")) - if day == none or clock == none { none } else { - day * 86400 + int(clock.captures.at(0)) * 3600 + int(clock.captures.at(1)) * 60 + int(clock.captures.at(2)) - } -} - -#let catalog-correlation(events, day-first: false) = { +#let catalog-correlation(events) = { let checksums = events.filter(event => event.provider == "ESENT" and event.id == "474" and lower(event.message).contains("catroot2") and event.message.contains("-1018")) checksums.find(anchor => { - let time = event-second(anchor.time, day-first: day-first) + let time = datetime-second(anchor.time) let nearby = events.filter(event => { - let other = event-second(event.time, day-first: day-first) + let other = datetime-second(event.time) time != none and other != none and calc.abs(time - other) <= 120 }) - (nearby.any(event => event.provider == "Application Error" and event.id == "1000" and lower(event.message).contains("cryptsvc") and lower(event.message).contains("esent.dll")) and - nearby.any(event => event.provider == "Microsoft-Windows-WindowsUpdateClient" and event.id == "20")) + nearby.any(event => event.provider == "Application Error" and event.id == "1000" and lower(event.message).contains("cryptsvc") and lower(event.message).contains("esent.dll")) and nearby.any(event => event.provider == "Microsoft-Windows-WindowsUpdateClient" and event.id == "20") }) } -#let normalize(source, rules: (:), source-name: "WinDiagnostics dump") = { - let text = source.replace(regex("\\r"), "") - let sections = parse-sections(text) - let os = section(sections, "OPERATING SYSTEM / COMPUTER / BIOS") - let cpu = section(sections, "CPU") - let uptime = section(sections, "UPTIME") - let defender = section(sections, "WINDOWS DEFENDER STATUS") - let battery = section(sections, "BATTERY") - let storage = section(sections, "STORAGE / FREE SPACE / HEALTH") - let generated = field(text, "Generated") - // Compare the local capture date with the ISO header; do not assume US dates. - let local-date = field(os, "LocalDateTime") - let day-first = event-day(local-date, day-first: true) == report-day(generated) and event-day(local-date) != report-day(generated) - let raw-events = parse-events(sections) - let events = group-events(raw-events, rules, reference-day: report-day(generated), day-first: day-first) +#let command-output(report, name) = { + let item = section-first(report, name) + let output = get(item, "output", get(section(report, name), "legacy_raw", ())) + let text = if type(output) == array { output.map(value => str(value)).join("\n", default: "") } else { str(output) } + text.replace("\r", "\n").split("\n").filter(line => line.trim() != "" and not lower(line).contains("% complete")).join("\n", default: "") +} +#let object-lines(item, fields) = { + fields.map(pair => pair.at(0) + ": " + str(get(item, pair.at(1), "Unknown"))).join("\n", default: "") +} + +#let normalize(report, rules: (:), source-name: "WinDiagnostics JSON") = { + let schema = get(report, "schema_version", 0) + if schema != 1 { panic("Unsupported WinDiagnostics schema_version: " + str(schema)) } + + let generated-raw = get(report, "generated_at", "Unknown") + let generated = if generated-raw == "Unknown" { "Unknown" } else { display-date(generated-raw) } + let reference-day = datetime-day(generated-raw) + let host = get(report, "host", (:)) + let mode = str(get(report, "mode", "Unknown")) + let administrator = get(host, "administrator", false) + + // Full/Mid reports use sections. Compact reports use summary. + let compact = lower(mode) == "compact" + let summary = get(report, "summary", (:)) + + let os = if compact { get(summary, "operating_system", (:)) } else { section-first(report, "operating_system") } + let system = if compact { get(summary, "system", (:)) } else { section-first(report, "computer_system") } + let cpu = if compact { get(summary, "cpu", (:)) } else { section-first(report, "cpu") } + let uptime = if compact { get(summary, "uptime", (:)) } else { section-first(report, "uptime") } + + let defender = if compact { get(summary, "defender", (:)) } else { section-first(report, "defender") } + let battery = if compact { (:) } else { section-first(report, "battery") } + + let storage-root = if compact { get(summary, "storage", (:)) } else { section-first(report, "storage") } + let logical-volumes = if compact { get(storage-root, "logical_volumes", ()) } else { get(storage-root, "logical_volumes", ()) } + + let raw = if compact { () } else { raw-events(report) } + let events = group-events(raw, rules, reference-day: reference-day) let findings = () - let catalog-cluster = catalog-correlation(raw-events, day-first: day-first) + if get(report, "legacy", none) != none { + findings.push((severity: "warning", title: "Legacy conversion has incomplete evidence", detail: "This report was converted from formatted text. Table rows and event-message formatting may have been lost. Unrecoverable inventories and device/firewall states are unavailable; empty converted storage is not evidence that no disks exist. Legacy event dates retain their original format and receive no age discount.", confidence: 100, weight_factor: 0, resolution_steps: ("Collect a new native JSON report with WinDiagnostics Full to replace incomplete evidence.",))) + } + for warning in get(report, "warnings", ()) { + findings.push((severity: "warning", title: "Collector warning", detail: str(warning), confidence: 100, weight_factor: 0)) + } + for (name, value) in get(report, "sections", (:)).pairs() { + if get(value, "status", "") in ("error", "skipped") { + findings.push((severity: "warning", title: "Collector coverage: " + name, detail: get(value, "status", "") + ": " + str(get(value, "error", "No result collected")), confidence: 100, weight_factor: 0)) + } + } + + let catalog-cluster = catalog-correlation(raw) if catalog-cluster != none { - findings.push((severity: "critical", title: "Catalog corruption coincides with Cryptographic Services and update failures", detail: "Around " + catalog-cluster.time + ", CatRoot2 checksum failure (-1018), a CryptSvc crash in ESENT.dll, and Windows Update failure occur within two minutes of the checksum event. This supports a related failure sequence, but does not establish which hardware or software component caused the corruption. See the individual event evidence below.", confidence: 90, weight_factor: 0, resolution_steps: ("Back up important data and preserve event logs before resetting update components.", "Investigate storage and memory stability, including any ESENT memory warnings. Retest at stock CPU/RAM settings and review firmware guidance for the captured motherboard and CPU.", "Run Full diagnostics as administrator to obtain DISM and SFC results, then use those results to guide supported Windows component repair.", "Retry the failed update and verify Cryptographic Services remains stable with no new database checksum failures."))) + findings.push(( + severity: "critical", + title: "Catalog corruption coincides with Cryptographic Services and update failures", + detail: "Around " + display-time(catalog-cluster.time) + ", CatRoot2 checksum failure (-1018), a CryptSvc crash in ESENT.dll, and Windows Update failure occur within two minutes of the checksum event. This supports a related failure sequence, but does not establish which hardware or software component caused the corruption.", + confidence: 90, + weight_factor: 0, + resolution_steps: ( + "Back up important data and preserve event logs before resetting update components.", + "Investigate storage and memory stability. Retest at stock CPU/RAM settings and review firmware guidance for the captured motherboard and CPU.", + "Run Full diagnostics as administrator to obtain DISM and SFC results, then use those results to guide supported Windows component repair.", + "Retry the failed update and verify Cryptographic Services remains stable with no new database checksum failures.", + ), + )) } - if field(text, "Administrator") == "False" { - findings.push((severity: "warning", title: "Diagnostic coverage is incomplete", detail: "The collector was not elevated. Skipped administrator-only checks, including DISM and SFC, are not evidence of healthy system files.", confidence: 100, resolution_steps: ("Run WinDiagnostics Full from an elevated PowerShell session.", "Review the new DISM, SFC, and other previously skipped results before closing the investigation."))) + + if not administrator { + findings.push(( + severity: "warning", + title: "Diagnostic coverage is incomplete", + detail: "The collector was not elevated. Administrator-only checks, including DISM and SFC, may be skipped and are not evidence of healthy system files.", + confidence: 100, + resolution_steps: ( + "Run WinDiagnostics Full from an elevated PowerShell session.", + "Review the new DISM, SFC, and other previously skipped results before closing the investigation.", + ), + )) } - let dism = section(sections, "WINDOWS COMPONENT STORE STATUS") - let sfc = section(sections, "SYSTEM FILE CHECK - VERIFY ONLY") - if lower(dism).contains("repairable") { - findings.push((severity: "warning", title: "Windows component store is repairable", detail: "DISM found component-store corruption, but classified the image as repairable with RestoreHealth rather than non-repairable.", confidence: 98, resolution_steps: ("Open an elevated terminal and run DISM.exe /Online /Cleanup-Image /RestoreHealth.", "After DISM succeeds, run sfc /scannow.", "Re-run diagnostics and confirm both checks are healthy."), reference_url: "https://learn.microsoft.com/en-us/windows-hardware/manufacture/desktop/repair-a-windows-image?view=windows-11", reference_label: "Microsoft Windows image repair guidance")) + + let dism = if compact { "" } else { command-output(report, "component_store") } + let sfc = if compact { "" } else { command-output(report, "system_file_check") } + + if lower(dism).contains("repairable") and not lower(dism).contains("non-repairable") { + findings.push(( + severity: "warning", + title: "Windows component store is repairable", + detail: "DISM found component-store corruption and classified the image as repairable with RestoreHealth.", + confidence: 98, + resolution_steps: ( + "Open an elevated terminal and run DISM.exe /Online /Cleanup-Image /RestoreHealth.", + "After DISM succeeds, run sfc /scannow.", + "Re-run diagnostics and confirm both checks are healthy.", + ), + reference_url: "https://learn.microsoft.com/en-us/windows-hardware/manufacture/desktop/repair-a-windows-image?view=windows-11", + reference_label: "Microsoft Windows image repair guidance", + )) } - if lower(sfc).contains("integrity violations") { - findings.push((severity: "critical", title: "System-file integrity violations", detail: "SFC verification found integrity violations; review CBS.log and repair after DISM.", confidence: 98, resolution_steps: ("Repair the component store with DISM.exe /Online /Cleanup-Image /RestoreHealth.", "Run sfc /scannow after DISM completes.", "Re-run verification and confirm that no integrity violations remain."), reference_url: "https://support.microsoft.com/en-us/windows/experience/backup-recovery/using-system-file-checker-in-windows", reference_label: "Microsoft SFC and DISM guidance")) + + if lower(sfc).contains("integrity violations") and not lower(sfc).contains("did not find any integrity violations") { + findings.push(( + severity: "critical", + title: "System-file integrity violations", + detail: "SFC verification found integrity violations; review CBS.log and repair after DISM.", + confidence: 98, + resolution_steps: ( + "Repair the component store with DISM.exe /Online /Cleanup-Image /RestoreHealth.", + "Run sfc /scannow after DISM completes.", + "Re-run verification and confirm that no integrity violations remain.", + ), + reference_url: "https://support.microsoft.com/en-us/windows/experience/backup-recovery/using-system-file-checker-in-windows", + reference_label: "Microsoft SFC and DISM guidance", + )) } + for event in events { - if event.severity == "critical" or event.severity == "warning" or event.severity == "unanalysed" { - findings.push((severity: event.severity, title: event.provider + " · Event " + event.id, detail: event.message + " " + event.rationale, remediation: event.remediation, resolution_steps: event.resolution_steps, reference_url: event.reference_url, reference_label: event.reference_label, confidence: event.confidence, count: event.count, weight_factor: event.weight_factor, age_days: event.age_days, fading: event.fading)) + if event.severity in ("critical", "warning", "unanalysed") { + findings.push(( + severity: event.severity, + title: event.provider + " · Event " + event.id, + detail: event.message + " " + event.rationale, + remediation: event.remediation, + resolution_steps: event.resolution_steps, + reference_url: event.reference_url, + reference_label: event.reference_label, + confidence: event.confidence, + count: event.count, + weight_factor: event.weight_factor, + age_days: event.age_days, + fading: event.fading, + )) } } - let problems = section(sections, "DEVICES WITH PROBLEMS") - let disabled-displays = useful-lines(problems).filter(line => line.match(regex("^Error[ \t]+Display[ \t]+")) != none and line.contains("CM_PROB_DISABLED")) - for device in disabled-displays { - let name = capture(device, "^Error[ \t]+Display[ \t]+(.*?)[ \t]+PCI", default: "Display adapter") - findings.push((severity: "warning", title: name + " is disabled (Code 22)", detail: "The device reports CM_PROB_DISABLED. This records a disabled device, not proof of GPU hardware failure. The dump does not establish who or what disabled it.", confidence: 99, resolution_steps: ("Open Device Manager > Display adapters and inspect this adapter's status and Events tab.", "If it should be active, select Enable device and record any new status code.", "Restart and verify display acceleration and normal workload stability. If enabling fails or the device becomes disabled again, collect device events and review the installed vendor driver.", "Investigate concurrent IOMMU and memory/storage errors separately; this dump does not map the IOMMU device identifier to the GPU."), reference_url: "https://learn.microsoft.com/en-us/windows-hardware/drivers/install/cm-prob-disabled", reference_label: "Microsoft Code 22 guidance")) + + let problem-devices = if compact { () } else { section-data(report, "problem_devices") } + for device in problem-devices { + if get(device, "Class", "") == "Display" and (get(device, "ConfigManagerErrorCode", 0) == 22 or str(get(device, "Problem", "")).contains("CM_PROB_DISABLED")) { + findings.push((severity: "warning", title: str(get(device, "FriendlyName", get(device, "Name", "Display adapter"))) + " is disabled (Code 22)", detail: "The device is disabled. This does not establish GPU hardware failure or who disabled it.", confidence: 99, resolution_steps: ("Inspect the adapter status and Events tab in Device Manager.", "If it should be active, enable it, restart, and verify acceleration and workload stability."))) + } } - let other-problems = useful-lines(problems).filter(line => line.starts-with("Error") and not (line in disabled-displays)) - if problems != "" and not lower(problems).contains("no problem devices found") and (disabled-displays.len() == 0 or other-problems.len() > 0) { - findings.push((severity: "warning", title: "Devices report problems", detail: "One or more present devices did not report OK status.", confidence: 90, resolution_steps: ("Identify every reported device in Device Manager.", "Update, repair, or remove the associated driver or disconnected hardware.", "Re-run diagnostics and confirm that no present device reports a problem."))) - } - let disk-free = () - for match in storage.matches(regex("(?m)^([A-Z]:)[ \\t]+.*?[ \\t](\\d+(?:[.,]\\d+)?)[ \\t]+(\\d+(?:[.,]\\d+)?)[ \\t]+(\\d+(?:[.,]\\d+)?)[ \\t]*$")) { - disk-free.push((drive: match.captures.at(0), size_gb: number(match.captures.at(1)), free_gb: number(match.captures.at(2)), free_percent: number(match.captures.at(3)))) + if problem-devices.len() > 0 or (compact and get(get(summary, "devices", (:)), "problem_count", 0) > 0) { + findings.push(( + severity: "warning", + title: "Devices report problems", + detail: str(if compact { get(get(summary, "devices", (:)), "problem_count", 0) } else { problem-devices.len() }) + " present device(s) did not report a healthy state.", + confidence: 90, + resolution_steps: ( + "Identify every reported device in Device Manager.", + "Update, repair, enable, or remove the associated driver or disconnected hardware as appropriate.", + "Re-run diagnostics and confirm that no present device reports a problem.", + ), + )) } - let inventory-map = ( - ("Desktop programs", "INSTALLED PROGRAMS"), - ("Store packages", "MICROSOFT STORE / APPX PACKAGES"), - ("Automatic services", "AUTOMATIC SERVICES"), - ("Signed drivers", "SIGNED DRIVERS"), - ("Hotfixes", "WINDOWS UPDATES / HOTFIXES"), - ("Scheduled tasks", "NON-MICROSOFT SCHEDULED TASKS"), - ("Startup programs", "STARTUP PROGRAMS"), - ("Listening endpoints", "ACTIVE TCP LISTENERS"), - ) - let inventory = inventory-map.map(pair => (label: pair.at(0), count: table-count(section(sections, pair.at(1))))) + let disk-free = logical-volumes.map(disk => ( + drive: str(get(disk, "drive", get(disk, "DeviceID", "Disk"))), + size_gb: number(get(disk, "size_gb", 0)), + free_gb: number(get(disk, "free_gb", 0)), + free_percent: number(get(disk, "free_percent", 0)), + )) - let excerpt-names = ( - "OPERATING SYSTEM / COMPUTER / BIOS", "CPU", "MEMORY MODULES", "MOTHERBOARD", - "GPU / DISPLAY ADAPTERS", "STORAGE / FREE SPACE / HEALTH", "DEVICES WITH PROBLEMS", - "NETWORK ADAPTERS", "WINDOWS COMPONENT STORE STATUS", "SYSTEM FILE CHECK - VERIFY ONLY", + let low-disk = disk-free.filter(disk => disk.free_percent < 10) + if low-disk.len() > 0 { + findings.push(( + severity: "warning", + title: "Low storage headroom", + detail: low-disk.map(disk => disk.drive + " has " + str(disk.free_percent) + "% free space").join("; ") + ".", + confidence: 100, + resolution_steps: ( + "Review large or temporary files on the affected volume.", + "Preserve sufficient free space for Windows servicing, updates, paging, and application workloads.", + "Re-run diagnostics after cleanup and confirm storage headroom has recovered.", + ), + )) + } + + let firewall = if compact { () } else { section-data(report, "firewall_profiles") } + let firewall-ok = firewall.len() == 0 or firewall.all(item => enabled(get(item, "Enabled", none))) + if firewall.len() > 0 and not firewall-ok { + findings.push(( + severity: "critical", + title: "Windows Firewall protection is incomplete", + detail: "At least one captured firewall profile is disabled.", + confidence: 95, + resolution_steps: ( + "Confirm that organization policy does not intentionally disable the profile.", + "Otherwise enable the required Domain, Private, and Public profiles in elevated PowerShell.", + "Verify the resulting profile state and re-run diagnostics.", + ), + reference_url: "https://learn.microsoft.com/en-us/windows/security/operating-system-security/network-security/windows-firewall/configure-with-command-line", + reference_label: "Microsoft firewall command guidance", + )) + } + + let defender-ok = defender != (:) and ( + get(defender, "AntivirusEnabled", false) == true and + get(defender, "AntispywareEnabled", false) == true and + get(defender, "RealTimeProtectionEnabled", false) == true and + get(defender, "BehaviorMonitorEnabled", false) == true and + get(defender, "IoavProtectionEnabled", false) == true and + get(defender, "NISEnabled", false) == true ) + + let battery-charge = number(get(battery, "EstimatedChargeRemaining", 0)) + let battery-present = battery != (:) + let battery-ok = not battery-present or (str(get(battery, "Status", "Unknown")) == "OK" and battery-charge >= 20) + + let inventory = if compact { + let software = get(summary, "software", (:)) + let startup = get(summary, "startup", (:)) + let services = get(summary, "services", (:)) + ( + (label: "Desktop programs", count: get(software, "desktop_program_count", 0)), + (label: "Store packages", count: get(software, "appx_package_count", 0)), + (label: "Startup commands", count: get(startup, "command_count", 0)), + (label: "Automatic services", count: get(services, "automatic_count", 0)), + ) + } else { + ( + (label: "Desktop programs", count: section-count(report, "installed_programs")), + (label: "Store packages", count: section-count(report, "appx_packages")), + (label: "Automatic services", count: section-count(report, "automatic_services")), + (label: "Signed drivers", count: section-count(report, "signed_drivers")), + (label: "Hotfixes", count: section-count(report, "hotfixes")), + (label: "Scheduled tasks", count: section-count(report, "non_microsoft_scheduled_tasks")), + (label: "Startup programs", count: section-count(report, "startup_programs")), + (label: "Listening endpoints", count: section-count(report, "active_tcp_listeners")), + ) + } + let excerpts = () - for name in excerpt-names { - let value = section(sections, name) - if value != "" { - let level = "info" - if name == "OPERATING SYSTEM / COMPUTER / BIOS" { - value = value.replace(regex("\\n[ \\t]*\\n+"), "\\n") - } - if name == "CPU" { - value = "Name: " + field(value, "Name") + "\\nCores: " + field(value, "NumberOfCores", default: "?") - } - if name == "WINDOWS COMPONENT STORE STATUS" and not (lower(value).contains("repairable") or lower(value).contains("corrupt") or lower(value).contains("error")) { - value = "" - } - if name == "SYSTEM FILE CHECK - VERIFY ONLY" { - value = value.replace(regex("Verification \\d+% complete\\.[ \\t\\n]*"), "") - if lower(value).contains("integrity violations") { level = "critical" } - } - if value != "" { excerpts.push((title: name, text: value, severity: level)) } + for (name, title, fields) in ( + ("bios", "BIOS", (("Manufacturer", "Manufacturer"), ("Version", "Name"))), + ("motherboard", "MOTHERBOARD", (("Manufacturer", "Manufacturer"), ("Product", "Product"))), + ("memory_modules", "MEMORY MODULES", (("Capacity GB", "capacity_gb"), ("Configured clock", "ConfiguredClockSpeed"), ("Part number", "PartNumber"))), + ("gpus", "GPU / DISPLAY ADAPTERS", (("Name", "Name"), ("Driver", "DriverVersion"))), + ) { + let records = section-data(report, name) + if records.len() > 0 { + excerpts.push((title: title, severity: "info", text: records.map(item => object-lines(item, fields)).join("\n\n"))) } } - let firewall = section(sections, "FIREWALL PROFILES") - let firewall-vanilla = firewall != "" and firewall.matches(regex("(?m)^(Domain|Private|Public)[ \\t]+True[ \\t]+NotConfigured[ \\t]+NotConfigured[ \\t]*$")).len() == 3 - if firewall != "" and not firewall-vanilla { - excerpts.push((title: "FIREWALL PROFILES", text: firewall, severity: "warning")) - findings.push((severity: "warning", title: "Windows Firewall protection is incomplete", detail: "At least one standard firewall profile is disabled or differs from the expected enabled/default-policy state.", confidence: 95, resolution_steps: ("Confirm that organization policy does not intentionally disable the profile.", "Otherwise run Set-NetFirewallProfile -Profile Domain,Private,Public -Enabled True in elevated PowerShell.", "Verify that all three profiles report Enabled=True, then re-run diagnostics."), reference_url: "https://learn.microsoft.com/en-us/windows/security/operating-system-security/network-security/windows-firewall/configure-with-command-line", reference_label: "Microsoft firewall command guidance")) + let storage-health = get(storage-root, "storage_health", ()) + let unhealthy-storage = storage-health.filter(item => lower(str(get(item, "HealthStatus", "Healthy"))) != "healthy") + if unhealthy-storage.len() > 0 { + excerpts.push(( + title: "STORAGE HEALTH", + severity: "warning", + text: unhealthy-storage.map(item => object-lines(item, (("Disk", "FriendlyName"), ("Health", "HealthStatus"), ("Operational", "OperationalStatus")))).join("\n\n"), + )) } - let defender-ok = defender != "" and ( - field(defender, "AntivirusEnabled") == "True" and - field(defender, "AntispywareEnabled") == "True" and - field(defender, "RealTimeProtectionEnabled") == "True" and - field(defender, "BehaviorMonitorEnabled") == "True" and - field(defender, "IoavProtectionEnabled") == "True" and - field(defender, "NISEnabled") == "True" + + if problem-devices.len() > 0 { + excerpts.push(( + title: "DEVICES WITH PROBLEMS", + severity: "warning", + text: problem-devices.map(item => object-lines(item, (("Status", "Status"), ("Class", "Class"), ("Device", "FriendlyName"), ("Instance", "InstanceId")))).join("\n\n"), + )) + } + + if dism != "" and (lower(dism).contains("repairable") or lower(dism).contains("corrupt") or lower(dism).contains("error")) { + excerpts.push((title: "WINDOWS COMPONENT STORE STATUS", text: dism, severity: "warning")) + } + + if sfc != "" { + let sfc-level = if lower(sfc).contains("integrity violations") and not lower(sfc).contains("did not find any integrity violations") { "critical" } else { "info" } + excerpts.push((title: "SYSTEM FILE CHECK - VERIFY ONLY", text: sfc, severity: sfc-level)) + } + + if firewall.len() > 0 and not firewall-ok { + excerpts.push(( + title: "FIREWALL PROFILES", + severity: "warning", + text: firewall.map(item => object-lines(item, (("Profile", "Name"), ("Enabled", "Enabled"), ("Inbound", "DefaultInboundAction"), ("Outbound", "DefaultOutboundAction")))).join("\n\n"), + )) + } + + if defender != (:) and not defender-ok { + excerpts.push(( + title: "WINDOWS DEFENDER STATUS", + severity: "warning", + text: object-lines(defender, ( + ("Antivirus", "AntivirusEnabled"), + ("Antispyware", "AntispywareEnabled"), + ("Real-time", "RealTimeProtectionEnabled"), + ("Behavior monitor", "BehaviorMonitorEnabled"), + ("IOAV", "IoavProtectionEnabled"), + ("NIS", "NISEnabled"), + )), + )) + } + + if battery-present and not battery-ok { + excerpts.push(( + title: "BATTERY", + severity: if battery-charge < 10 { "critical" } else { "warning" }, + text: object-lines(battery, (("Name", "Name"), ("Status", "Status"), ("Charge", "EstimatedChargeRemaining"), ("Battery status", "BatteryStatus"))), + )) + } + + let inventory-sections = ( + "installed_programs", "appx_packages", "automatic_services", "signed_drivers", + "hotfixes", "non_microsoft_scheduled_tasks", "startup_programs", "active_tcp_listeners", + ) + let sensitive-sections = ("ip_configuration", "important_directories", "startup_folders", "dns_servers") + let routine-sections = ("automatic_services_not_running", "power_plan", "top_processes_by_memory") + let detailed-sections = ( + "storage", "problem_devices", "component_store", "system_file_check", "firewall_profiles", "defender", "battery", ) - if defender != "" and not defender-ok { - excerpts.push((title: "WINDOWS DEFENDER STATUS", text: defender, severity: "warning")) - } - let battery-charge = number(field(battery, "EstimatedChargeRemaining", default: "0")) - let battery-ok = battery == "" or (field(battery, "Status", default: "Unknown") == "OK" and battery-charge >= 20) - if battery != "" and not battery-ok { - excerpts.push((title: "BATTERY", text: battery, severity: if battery-charge < 10 { "critical" } else { "warning" })) - } - findings = findings.filter(item => item.severity == "critical") + findings.filter(item => item.severity == "warning") + findings.filter(item => item.severity == "unanalysed") let coverage = () - for (name, body) in sections.pairs() { - let included = excerpts.any(item => item.title == name) - let treatment = if included { "Detailed evidence" } - else if name.starts-with("RECENT ") and name.contains("ERRORS") { "Deduplicated findings" } - else if inventory-map.any(pair => pair.at(1) == name) { "Inventory count" } - else if name in ("IP CONFIGURATION", "IMPORTANT DIRECTORIES", "STARTUP FOLDERS", "DNS SERVERS") { "Reviewed; raw sensitive/noise-heavy values omitted" } - else if name in ("AUTOMATIC SERVICES NOT RUNNING", "POWER PLAN") { "Reviewed; routine snapshot omitted" } - else if name == "FIREWALL PROFILES" and firewall-vanilla { "Healthy vanilla configuration omitted" } - else if name == "WINDOWS DEFENDER STATUS" and defender-ok { "Healthy protection state omitted" } - else if name == "BATTERY" and battery-ok { "No actionable battery state omitted" } - else if name == "WINDOWS COMPONENT STORE STATUS" and not included { "Healthy result omitted" } - else { "Reviewed and summarized" } - let coverage-level = if name.starts-with("RECENT ") and name.contains("ERRORS") and events.any(event => event.severity == "critical") { "critical" } - else if included and excerpts.find(item => item.title == name).severity in ("critical", "warning") { excerpts.find(item => item.title == name).severity } - else if treatment.contains("omitted") or treatment.contains("Inventory") or treatment.contains("summarized") { "success" } - else { "info" } - coverage.push((section: name, use: treatment, lines: useful-lines(body).len(), severity: coverage-level)) + if compact { + coverage.push((section: "summary", use: "Compact structured summary", records: 1, severity: "info")) + } else { + for (name, value) in get(report, "sections", (:)).pairs() { + let status = get(value, "status", "missing") + let count = section-count(report, name) + let use = if legacy-incomplete(report, name) { "Legacy conversion incomplete; recollect JSON" } else if status == "skipped" { "Skipped by collector" } + else if status == "error" { "Collector error retained" } + else if name in ("recent_system_errors", "recent_application_errors") { "Deduplicated findings" } + else if name in inventory-sections { "Inventory count" } + else if name in sensitive-sections { "Reviewed; sensitive/noise-heavy values omitted" } + else if name in routine-sections { "Reviewed; routine snapshot omitted" } + else if name in detailed-sections { "Structured health evidence" } + else { "Retained in source; no specific analysis" } + + let severity = if legacy-incomplete(report, name) { "warning" } else if status == "error" { "warning" } + else if status == "skipped" { "warning" } + else if name in ("recent_system_errors", "recent_application_errors") and events.any(event => event.severity == "critical") { "critical" } + else { "success" } + + coverage.push((section: name, use: use, records: count, severity: severity)) + } } + findings = findings.filter(item => item.severity == "critical") + findings.filter(item => item.severity == "warning") + findings.filter(item => item.severity == "unanalysed") + let critical = findings.filter(item => item.severity == "critical").len() let warnings = findings.filter(item => item.severity == "warning").len() let unanalysed = findings.filter(item => item.severity == "unanalysed").len() + let penalty = 0.0 for finding in findings { let base = if finding.severity == "critical" { 8 } else if finding.severity == "warning" { 2 } else if finding.severity == "unanalysed" { 1 } else { 0 } penalty += base * get(finding, "weight_factor", 1.0) } let health-score = calc.round(calc.max(0, calc.min(100, 100 - penalty))) + let confidence-total = 0 for finding in findings { confidence-total += get(finding, "confidence", 50) } let analysis-confidence = if findings.len() == 0 { 80 } else { calc.round(confidence-total / findings.len()) } - let uptime-days = field(uptime, "Days", default: none) - let uptime-hours = field(uptime, "Hours", default: none) - let uptime-minutes = field(uptime, "Minutes", default: none) - let uptime-value = if uptime-days == none or uptime-hours == none or uptime-minutes == none { + + let uptime-value = if uptime == (:) { "Unanalysed" } else { - uptime-days + "d " + uptime-hours + "h " + uptime-minutes + "m" + str(get(uptime, "days", get(uptime, "Days", "?"))) + "d " + str(get(uptime, "hours", get(uptime, "Hours", "?"))) + "h " + str(get(uptime, "minutes", get(uptime, "Minutes", "?"))) + "m" } + + let os-name = str(get(os, "caption", get(os, "Caption", "Unknown"))) + let os-version = str(get(os, "version", get(os, "Version", "Unknown"))) + let os-build = str(get(os, "build_number", get(os, "BuildNumber", "Unknown"))) + let manufacturer = str(get(system, "manufacturer", get(system, "Manufacturer", "Unknown"))) + let model = str(get(system, "model", get(system, "Model", "Unknown"))) + let cpu-name = str(get(cpu, "name", get(cpu, "Name", "Unknown"))) + let cores = get(cpu, "cores", get(cpu, "NumberOfCores", "?")) + let threads = get(cpu, "logical_processors", get(cpu, "NumberOfLogicalProcessors", "?")) + + let ram-total = if compact { + number(get(get(summary, "memory", (:)), "total_gb", 0)) + } else { + number(get(system, "total_physical_memory_gb", 0)) + } + let ram-free = if compact { + number(get(get(summary, "memory", (:)), "free_gb", 0)) + } else { + number(get(os, "free_memory_gb", 0)) + } + ( source: source-name, - mode: field(text, "Mode"), + schema_version: schema, + mode: mode, generated: generated, - computer: field(text, "Computer"), - administrator: field(text, "Administrator"), + computer: str(get(host, "computer_name", "Unknown")), + administrator: bool-text(administrator), health: if critical > 0 { "Attention required" } else if warnings > 0 or unanalysed > 0 { "Review recommended" } else { "No actionable issue detected" }, health_score: health-score, analysis_confidence: analysis-confidence, system: ( - os: field(os, "Caption"), version: field(os, "Version"), build: field(os, "BuildNumber"), - manufacturer: field(os, "Manufacturer"), model: field(os, "Model"), cpu: field(cpu, "Name"), - cores: field(cpu, "NumberOfCores", default: "?"), threads: field(cpu, "NumberOfLogicalProcessors", default: "?"), - ram_total_gb: number(field(os, "TotalMemoryGB", default: "0")), ram_free_gb: number(field(os, "FreeMemoryGB", default: "0")), + os: os-name, + version: os-version, + build: os-build, + manufacturer: manufacturer, + model: model, + cpu: cpu-name, + cores: cores, + threads: threads, + ram_total_gb: ram-total, + ram_free_gb: ram-free, uptime: uptime-value, ), - security: (antivirus: field(defender, "AntivirusEnabled"), realtime: field(defender, "RealTimeProtectionEnabled"), signatures: field(defender, "AntivirusSignatureLastUpdated")), - battery: (charge: number(field(battery, "EstimatedChargeRemaining", default: "0")), status: field(battery, "Status", default: "Unavailable")), - disk_free: disk-free, inventory: inventory, findings: findings, - issue_counts: (critical: critical, warning: warnings, unanalysed: unanalysed), event_groups: events, - excerpts: excerpts, coverage: coverage, + security: ( + antivirus: bool-text(get(defender, "AntivirusEnabled", "Unavailable")), + realtime: bool-text(get(defender, "RealTimeProtectionEnabled", "Unavailable")), + signatures: display-time(get(defender, "AntivirusSignatureLastUpdated", "Unavailable")), + ), + battery: ( + charge: battery-charge, + status: str(get(battery, "Status", "Unavailable")), + ), + disk_free: disk-free, + inventory: inventory, + findings: findings, + issue_counts: (critical: critical, warning: warnings, unanalysed: unanalysed), + event_groups: events.map(event => { + event.insert("display_time", display-time(event.time)) + event + }), + excerpts: excerpts, + coverage: coverage, ) } diff --git a/diagnostics-rules.yaml b/diagnostics-rules.yaml index 48844d8..eb7dfcf 100644 --- a/diagnostics-rules.yaml +++ b/diagnostics-rules.yaml @@ -1,6 +1,24 @@ # WinDiagnostics interpretation rules. # Add or revise entries here as new event providers and IDs are understood. event_rules: + - provider: "Microsoft-Windows-WER-SystemErrorReporting" + id: "1001" + severity: "critical" + confidence: 100 + rationale: "Windows reports a reboot following a kernel bugcheck. The stop code and saved dump are evidence of a crash, but do not identify the responsible driver or hardware on their own." + resolution_steps: + - "Preserve the referenced minidump and the System event log." + - "Open the dump in WinDbg and run !analyze -v; review the bugcheck parameters and stack before attributing the crash to a component." + - "Correlate the crash with nearby storage, device, and driver events. Apply targeted OEM driver or firmware fixes supported by the dump analysis." + - "Reproduce the original workload and verify that no new bugcheck occurs in a subsequent capture." + reference_url: "https://learn.microsoft.com/en-us/windows-hardware/drivers/debugger/bug-check-code-reference2" + reference_label: "Microsoft bugcheck reference" + - provider: "volmgr" + id: "162" + severity: "info" + confidence: 100 + rationale: "The collector message records successful crash-dump generation. This is supporting crash evidence, not an additional storage failure." + remediation: "Preserve the dump and investigate the associated bugcheck." - provider: "stornvme" id: "11" severity: "critical" diff --git a/diagnostics.typ b/diagnostics.typ index 50dcbbb..d195bf5 100644 --- a/diagnostics.typ +++ b/diagnostics.typ @@ -1,5 +1,5 @@ #import "diagnostics-model.typ": diagnostics-model -#import "diagnostics-normalize.typ": normalize +#import "diagnostics-normalize.typ": normalize, datetime-day #let diagnostics-file = sys.inputs.at("diagnostics", default: none) #let author = sys.inputs.at("author", default: none) @@ -7,7 +7,7 @@ #if diagnostics-file == none { panic( "Missing diagnostics input.\n" + - "Usage: typst compile --input diagnostics=diagnostics/file.txt " + + "Usage: typst compile --input diagnostics=diagnostics/file.json " + "--input author=\"Your name\" diagnostics.typ output.pdf" ) } @@ -19,14 +19,30 @@ ) } -#let source = read(diagnostics-file, encoding: "utf8") +#let source = json(diagnostics-file) + +#if source.at("report_type", default: "") != "windows_system_maintenance" { + panic( + "Unsupported diagnostics JSON.\n" + + "Expected report_type=\"windows_system_maintenance\" in " + diagnostics-file + ) +} + +#if source.at("schema_version", default: 0) != 1 { + panic( + "Unsupported WinDiagnostics schema version: " + + str(source.at("schema_version", default: "missing")) + + ". This renderer currently supports schema_version 1." + ) +} + #let rules = yaml("diagnostics-rules.yaml") #let data = normalize(source, rules: rules, source-name: diagnostics-file) -#if data.at("generated", default: "Unknown") == "Unknown" { +#if datetime-day(source.at("generated_at", default: "")) == none { panic( "Missing required diagnostics date.\n" + - "The WinDiagnostics dump must contain a Generated: date in its header." + "The WinDiagnostics JSON must contain generated_at." ) } diff --git a/docs/diagnostics.md b/docs/diagnostics.md index 7ef4acf..de897bf 100644 --- a/docs/diagnostics.md +++ b/docs/diagnostics.md @@ -1,15 +1,15 @@ # Diagnostics reports -`diagnostics.typ` generates a synthetic Windows health assessment from the text -dump produced by `windiagnostics/WindowsMaintenanceReport.ps1`. +`diagnostics.typ` generates a synthetic Windows health assessment from the structured JSON +report produced by `windiagnostics/WindowsMaintenanceReport.ps1`. ## Quick start -Collect a Full report on Windows, copy the resulting `.txt` file into +Collect a Full report on Windows, copy the resulting `.json` file into `diagnostics/`, then run from this repository: ```bash -./render-diagnostics.sh diagnostics/windows_system_report_PC.txt "Your Name" +./render-diagnostics.sh diagnostics/windows_system_report_PC.json "Your Name" ``` The theme is optional and defaults to `default`. @@ -17,10 +17,10 @@ The theme is optional and defaults to `default`. Choose a theme with the optional third argument: ```bash -./render-diagnostics.sh diagnostics/windows_system_report_PC.txt "Your Name" eridani +./render-diagnostics.sh diagnostics/windows_system_report_PC.json "Your Name" eridani ``` -Render every `.txt` dump under `diagnostics/` recursively: +Render every `.json` dump under `diagnostics/` recursively: ```bash ./render-diagnostics.sh --all "Your Name" @@ -41,21 +41,20 @@ The command creates: build/diagnostics/windows_system_report_PC.pdf ``` -The author is mandatory. The diagnostic date comes from the dump's `Generated:` -header and is also mandatory. Missing values stop compilation with an explicit +The author is mandatory. The diagnostic date comes from the report's `generated_at` field and is also mandatory. Missing values stop compilation with an explicit message. ## Pipeline -1. `diagnostics-normalize.typ` parses the PowerShell text transcript, +1. `diagnostics-normalize.typ` reads WinDiagnostics schema version 1 JSON, deduplicates event records, classifies signals, and builds normalized data entirely inside Typst. 2. `diagnostics.typ` validates the inputs and selected YAML theme. 3. `diagnostics-model.typ` renders the final PDF and uses PrimaViz for the summary visualization. -No Python, JSON conversion, or external normalization step is used. Typst reads -the `.txt` dump directly. It downloads `@preview/primaviz:0.10.0` on the first +No Python conversion or external normalization step is required for native captures. Typst reads +the `.json` dump directly. It downloads `@preview/primaviz:0.10.0` on the first build and caches it locally. The normalizer also correlates CatRoot2 checksum errors with CryptSvc crashes @@ -171,7 +170,7 @@ new diagnostic capture. It does not mean deleting evidence from Event Viewer. Use this workflow for each item in the PDF's **Resolution plan**: -1. Save the original PDF and text dump if the issue may need escalation or an +1. Save the original PDF and JSON capture if the issue may need escalation or an audit trail. 2. Follow the finding's numbered **Resolution path**. Use its linked vendor or Microsoft guidance when one is provided. @@ -216,7 +215,7 @@ resolution path remain in the report. A faded finding shows its age-adjusted weight beside the finding text. Age is measured from the event timestamp to the diagnostic report date in the -dump's `Generated:` header. It never uses the current date or the date on which +report's `generated_at` field. It never uses the current date or the date on which the PDF happens to be compiled. If either date cannot be parsed, full weight is retained. @@ -261,11 +260,11 @@ classification is heuristic; the PDF says so explicitly. ## Direct Typst usage -The original text dump is passed directly to Typst: +The JSON capture is passed directly to Typst: ```bash typst compile \ - --input diagnostics=diagnostics/windows_system_report_PC.txt \ + --input diagnostics=diagnostics/windows_system_report_PC.json \ --input author="Your Name" \ --input theme=cic \ diagnostics.typ \ @@ -277,7 +276,40 @@ Available themes are `default`, `cic`, and `eridani` and are defined in ## Input expectations -The parser is designed for Compact, Mid, and Full WinDiagnostics transcripts, -but Full provides the evidence needed for meaningful fault synthesis. Unknown -future sections still appear in the coverage table and are marked as reviewed -and summarized. +The parser is designed for Compact, Mid, and Full WinDiagnostics JSON captures, +but Full provides the evidence needed for meaningful fault synthesis. Unknown future sections remain listed in coverage as retained in the source without specific analysis. + +## JSON migration and converted captures + +The schema follows [WindowsMaintenanceReport.ps1](https://proxy.dandaedre.com/gitea/Beffroi/WinDiagnostics/raw/branch/main/WindowsMaintenanceReport.ps1). +The renderer validates `report_type`, `schema_version`, and `generated_at`. +Full/Mid captures use section envelopes (`status`, `count`, `data`, `error`); +Compact captures use `summary`. Collector warnings and skipped/error sections +remain visible. Coverage counts are records, not transcript lines. + +Native PowerShell dates may use `/Date(milliseconds)/`; ISO timestamps and their +offsets are also supported for event correlation. Firewall `Enabled` accepts +JSON `true` and the collector's numeric enum value `1`. DISM/SFC output remains +text inside JSON; progress lines are removed before displaying evidence. + +The existing `hardware-*` captures were converted with a lossy converter. It +changed CIM keys to snake_case, split event-message fields, and mistook table +separators for section headings. Several inventories contain only headers, +storage volumes are missing, and an empty section name contains displaced data. +These source files are preserved. The renderer accepts recoverable field aliases, +retains extra event-message fields, and reads command conclusions from +`legacy_raw`. Header-only inventory counts display **Unavailable**; unparsed +device/firewall tables do not produce false device or disabled-firewall findings. +Every converted report receives an explicit incomplete-evidence finding. +Legacy local event timestamps are left unchanged without age fading or temporal +correlation because their date order/timezone is not established reliably. +Recollect native Full JSON to replace the missing evidence; the renderer cannot +reconstruct lost table rows reliably from these JSON files. + +Native event timestamps display as `YYYY-MM-DD HH:MM:SS UTC`, with raw timestamps +preserved internally for correlation and fading. WER-SystemErrorReporting 1001 +is a critical kernel-crash finding; code 0x133 is identified as +[DPC_WATCHDOG_VIOLATION](https://learn.microsoft.com/en-us/windows-hardware/drivers/debugger/bug-check-0x133-dpc-watchdog-violation). +The saved dump must be analyzed to identify the responsible component. +`volmgr` 162 records successful dump generation and is informational, so it +adds no health-score penalty and is omitted from actionable event evidence. diff --git a/render-diagnostics.sh b/render-diagnostics.sh index 536c86b..3d38169 100755 --- a/render-diagnostics.sh +++ b/render-diagnostics.sh @@ -6,20 +6,20 @@ DIAGNOSTICS_DIR="${ROOT_DIR}/diagnostics" BUILD_DIR="${ROOT_DIR}/build/diagnostics" usage() { - cat <<'EOF' + cat <<'EOF_USAGE' Usage: - ./render-diagnostics.sh DUMP.txt "Author Name" [theme] + ./render-diagnostics.sh REPORT.json "Author Name" [theme] ./render-diagnostics.sh --all "Author Name" [theme] Examples: - ./render-diagnostics.sh diagnostics/windows_system_report_PC.txt "Jane Doe" - ./render-diagnostics.sh diagnostics/windows_system_report_PC.txt "Jane Doe" cic + ./render-diagnostics.sh diagnostics/windows_system_report_PC.json "Jane Doe" + ./render-diagnostics.sh diagnostics/windows_system_report_PC.json "Jane Doe" cic ./render-diagnostics.sh --all "Jane Doe" ./render-diagnostics.sh --all "Jane Doe" eridani The theme is optional and defaults to "default". Available themes: default, cic, eridani -EOF +EOF_USAGE } die() { @@ -31,14 +31,14 @@ render_diagnostics() { local input="$1" local author="$2" local theme="$3" - - [[ -f "$input" ]] || die "diagnostics dump not found: $input" + [[ -f "$input" ]] || die "diagnostics JSON not found: $input" + [[ "$input" == *.json ]] || die "diagnostics input must be a .json file: $input" local input_abs input_abs="$(realpath "$input")" [[ "$input_abs" == "$ROOT_DIR/"* ]] \ - || die "diagnostics dump must be inside the repository: $input" + || die "diagnostics JSON must be inside the repository: $input" local input_typst="${input_abs#"$ROOT_DIR/"}" local relative_output @@ -78,10 +78,10 @@ render_all() { while IFS= read -r -d '' input; do found=1 render_diagnostics "$input" "$author" "$theme" - done < <(find "$DIAGNOSTICS_DIR" -type f -name '*.txt' -print0 | sort -z) + done < <(find "$DIAGNOSTICS_DIR" -type f -name '*.json' -print0 | sort -z) if [[ "$found" -eq 0 ]]; then - echo "No diagnostics .txt dumps found in $DIAGNOSTICS_DIR" + echo "No diagnostics .json reports found in $DIAGNOSTICS_DIR" return 0 fi @@ -108,7 +108,7 @@ main() { elif [[ -f "${ROOT_DIR}/$target" ]]; then render_diagnostics "${ROOT_DIR}/$target" "$author" "$theme" else - die "diagnostics dump not found: $target" + die "diagnostics JSON not found: $target" fi fi } diff --git a/tools/check-diagnostics.typ b/tools/check-diagnostics.typ index f48b788..a8d2df5 100644 --- a/tools/check-diagnostics.typ +++ b/tools/check-diagnostics.typ @@ -1,43 +1,102 @@ -#import "../diagnostics-normalize.typ": normalize, event-day, date-index +#import "../diagnostics-normalize.typ": normalize, datetime-day, date-index, datetime-second, catalog-correlation, group-events, display-time #let rules = yaml("../diagnostics-rules.yaml") -#let data = normalize(read("../diagnostics/windows_system_report_SAURON_20260911_135414.txt"), rules: rules) -#assert.eq(data.issue_counts.unanalysed, 0) -#for (provider, id, severity) in ( - ("Microsoft-Windows-DeviceAssociationService", "3505", "warning"), - ("Microsoft-Windows-HAL", "15", "warning"), - ("usbaudio2", "38", "warning"), - ("Microsoft-Windows-HAL", "21", "warning"), - ("ESENT", "419", "critical"), - ("ESENT", "474", "critical"), - ("ESENT", "907", "critical"), - ("Microsoft-Windows-Defrag", "264", "warning"), -) { - let event = data.event_groups.find(item => item.provider == provider and item.id == id) - assert(event != none, message: provider + " / " + id + " missing from parsed events") - assert.eq(event.severity, severity) - assert(event.remediation != "") -} +#let fixture = json("fixtures/windiagnostics-v1.json") +#let data = normalize(fixture, rules: rules, source-name: "tools/fixtures/windiagnostics-v1.json") + +#assert.eq(data.computer, "TEST-PC") +#assert.eq(data.mode, "Full") +#assert.eq(data.generated, "2026-09-14") +#assert.eq(data.administrator, "Yes") #assert.eq(data.system.ram_total_gb, 31.82) +#assert.eq(data.system.ram_free_gb, 12.5) #assert.eq(data.disk_free.len(), 2) -#assert.eq(data.disk_free.at(0).free_percent, 81.6) -#assert.eq(data.disk_free.at(1).free_percent, 54.4) -#assert(data.findings.any(item => item.title == "AMD Radeon RX 6500 XT is disabled (Code 22)")) -#assert(data.findings.any(item => item.title == "Diagnostic coverage is incomplete")) +#assert.eq(data.disk_free.at(0).drive, "C:") +#assert.eq(data.disk_free.at(0).free_percent, 40.0) +#assert.eq(data.disk_free.at(1).free_percent, 60.0) + +#let programs = data.inventory.find(item => item.label == "Desktop programs") +#assert(programs != none) +#assert.eq(programs.count, 42) + +#let service-event = data.event_groups.find(item => item.provider == "Service Control Manager" and item.id == "7000") +#assert(service-event != none, message: "Service Control Manager / 7000 missing from structured events") +#assert.eq(service-event.severity, "warning") +#assert(service-event.remediation != "" or service-event.resolution_steps.len() > 0) +#assert(data.findings.any(item => item.title == "Service Control Manager · Event 7000")) #assert(not data.findings.any(item => item.title == "System-file integrity violations")) -#let crashes = data.event_groups.find(item => item.provider == "Application Error") -#assert(crashes.message.contains("svchost.exe_CryptSvc")) -#assert(crashes.message.contains("RtkAudUService64.exe")) -#assert.eq(crashes.age_days, 0) -#assert.eq(event-day("11/09/2026", day-first: true), date-index(2026, 9, 11)) -#assert.eq(event-day("09/30/2026"), date-index(2026, 9, 30)) -#assert.eq(event-day("09/30/2026", day-first: true), none) -#let unknown = normalize("--- RECENT SYSTEM ERRORS ---\nTimeCreated : 09/11/2026\nId : 999\nProviderName : UnknownProvider\nMessage : Unrecognized event", rules: rules) +#assert(not data.findings.any(item => item.title == "Windows Firewall protection is incomplete")) + +#assert.eq(datetime-day("2026-09-14T15:00:00+02:00"), date-index(2026, 9, 14)) +#assert.eq(datetime-day("/Date(1789390800000)/"), date-index(2026, 9, 14)) + +// Unknown events must remain visible rather than being silently discarded. +#let unknown-report = ( + schema_version: 1, + report_type: "windows_system_maintenance", + mode: "Full", + generated_at: "2026-09-14T16:00:00+02:00", + host: (computer_name: "UNKNOWN-EVENT-PC", administrator: true), + sections: ( + recent_system_errors: ( + status: "ok", + count: 1, + data: ((TimeCreated: "2026-09-14T12:00:00+02:00", Id: 999, ProviderName: "UnknownProvider", Message: "Unrecognized event"),), + error: none, + ), + recent_application_errors: (status: "ok", count: 0, data: (), error: none), + ), +) +#let unknown = normalize(unknown-report, rules: rules) #assert.eq(unknown.issue_counts.unanalysed, 1) -#let cluster-title = "Catalog corruption coincides with Cryptographic Services and update failures" -#assert(data.findings.any(item => item.title == cluster-title)) -#let no-update = normalize(read("../diagnostics/windows_system_report_SAURON_20260911_135414.txt").replace("Microsoft-Windows-WindowsUpdateClient", "UnrelatedProvider"), rules: rules) -#assert(not no-update.findings.any(item => item.title == cluster-title)) -#let distant-update = normalize(read("../diagnostics/windows_system_report_SAURON_20260911_135414.txt").replace("11/09/2026 10:45:56", "10/09/2026 10:45:56"), rules: rules) -#assert(not distant-update.findings.any(item => item.title == cluster-title)) -Diagnostics regression checks passed. + +Diagnostics JSON regression checks passed. + +#let native = normalize(json("../diagnostics/windows_system_report_DESKTOP-SAU019H_20260914_163753.json"), rules: rules) +#assert.eq(native.system.cores, 8) +#assert.eq(native.disk_free.at(0).free_percent, 51.4) +#assert.eq(native.event_groups.map(item => item.count).sum(), 33) +#assert(not native.findings.any(item => item.title == "Windows Firewall protection is incomplete")) +#let legacy = normalize(json("../diagnostics/hardware-17-tA6kwqAg-windows-system-report-desktop-2osf051-20260904-134702.json"), rules: rules) +#assert.eq(legacy.system.cores, 8) +#assert.eq(legacy.security.antivirus, "Yes") +#assert.eq(legacy.inventory.at(0).count, "Unavailable") +#assert(legacy.findings.any(item => item.title == "Legacy conversion has incomplete evidence")) +#assert(legacy.findings.any(item => item.title == "Windows component store is repairable")) +#assert(not legacy.findings.any(item => item.title == "Devices report problems")) +#assert(not legacy.findings.any(item => item.title == "Windows Firewall protection is incomplete")) +#assert(legacy.event_groups.any(item => item.provider == "Application Error" and item.message.contains("0xc0000409"))) +#assert.eq(datetime-second("1970-01-01T01:00:00+01:00"), datetime-second("/Date(0)/")) +#let cluster = ( + (provider: "ESENT", id: "474", time: "1970-01-01T01:00:00+01:00", message: "catroot2 -1018"), + (provider: "Application Error", id: "1000", time: "/Date(1000)/", message: "CryptSvc ESENT.dll"), + (provider: "Microsoft-Windows-WindowsUpdateClient", id: "20", time: "1970-01-01T00:02:00Z", message: "Update failed"), +) +#assert(catalog-correlation(cluster) != none) +#assert.eq(catalog-correlation(cluster.slice(0, 2)), none) +#let distant = cluster +#{ distant.at(2).time = "1970-01-01T00:02:01Z" } +#assert.eq(datetime-second(distant.at(2).time), 121) +#assert.eq(catalog-correlation(distant), none) +#let repeated = group-events(( + (provider: "Service Control Manager", id: "7000", time: "2026-01-01T00:00:00Z", message: "Failure"), + (provider: "Service Control Manager", id: "7000", time: "2026-09-14T00:00:00Z", message: "Failure"), +), rules, reference-day: date-index(2026, 9, 14)) +#assert.eq(repeated.at(0).age_days, 0) +#assert.eq(repeated.at(0).weight_factor, 1.0) +#let compact = normalize((schema_version: 1, mode: "Compact", generated_at: "2026-09-14T00:00:00Z", host: (administrator: true), summary: (memory: (total_gb: 16, free_gb: 8), devices: (problem_count: 1)))) +#assert.eq(compact.system.ram_total_gb, 16) +#assert(compact.findings.any(item => item.title == "Devices report problems")) + +#assert.eq(native.issue_counts.unanalysed, 0) +#let bugcheck = native.event_groups.find(item => item.provider == "Microsoft-Windows-WER-SystemErrorReporting" and item.id == "1001") +#assert.eq(bugcheck.severity, "critical") +#assert(bugcheck.message.contains("DPC_WATCHDOG_VIOLATION")) +#assert.eq(bugcheck.display_time, "2026-09-14 12:49:36 UTC") +#let dump = native.event_groups.find(item => item.provider == "volmgr" and item.id == "162") +#assert.eq(dump.severity, "info") +#assert(not native.findings.any(item => item.title == "volmgr · Event 162")) +#assert.eq(display-time("/Date(0)/"), "1970-01-01 00:00:00 UTC") +#assert.eq(display-time("/Date(-1000)/"), "1969-12-31 23:59:59 UTC") +#assert.eq(display-time("2026-09-14T15:29:36+02:00"), "2026-09-14 13:29:36 UTC") +#assert.eq(display-time("Unknown"), "Unknown") diff --git a/tools/fixtures/windiagnostics-v1.json b/tools/fixtures/windiagnostics-v1.json new file mode 100644 index 0000000..42215c9 --- /dev/null +++ b/tools/fixtures/windiagnostics-v1.json @@ -0,0 +1,186 @@ +{ + "schema_version": 1, + "report_type": "windows_system_maintenance", + "mode": "Full", + "generated_at": "2026-09-14T16:00:00+02:00", + "completed_at": "2026-09-14T16:01:00+02:00", + "host": { + "computer_name": "TEST-PC", + "user_name": "CI", + "administrator": true, + "powershell_version": "7.6.6" + }, + "parameters": { + "event_log_days": 7, + "max_event_errors": 100 + }, + "warnings": [], + "summary": null, + "sections": { + "operating_system": { + "status": "ok", + "count": 1, + "data": [ + { + "Caption": "Microsoft Windows 11 Pro", + "Version": "10.0.26200", + "BuildNumber": "26200", + "OSArchitecture": "64-bit", + "free_memory_gb": 12.5, + "total_memory_gb": 31.8 + } + ], + "error": null + }, + "computer_system": { + "status": "ok", + "count": 1, + "data": [ + { + "Manufacturer": "Test Vendor", + "Model": "Test Model", + "SystemType": "x64-based PC", + "total_physical_memory_gb": 31.82 + } + ], + "error": null + }, + "cpu": { + "status": "ok", + "count": 1, + "data": [ + { + "Name": "Test CPU", + "NumberOfCores": 8, + "NumberOfLogicalProcessors": 16 + } + ], + "error": null + }, + "uptime": { + "status": "ok", + "count": 1, + "data": [ + { + "last_boot": "2026-09-13T12:00:00+02:00", + "days": 1, + "hours": 4, + "minutes": 0 + } + ], + "error": null + }, + "storage": { + "status": "ok", + "count": 1, + "data": [ + { + "logical_volumes": [ + { + "DeviceID": "C:", + "VolumeName": "Windows", + "FileSystem": "NTFS", + "size_gb": 1000.0, + "free_gb": 400.0, + "free_percent": 40.0 + }, + { + "DeviceID": "D:", + "VolumeName": "Data", + "FileSystem": "NTFS", + "size_gb": 2000.0, + "free_gb": 1200.0, + "free_percent": 60.0 + } + ], + "physical_disks": [], + "storage_health": [], + "reliability_counters": [], + "reliability_requires_admin": true + } + ], + "error": null + }, + "installed_programs": {"status": "ok", "count": 42, "data": [], "error": null}, + "appx_packages": {"status": "ok", "count": 20, "data": [], "error": null}, + "automatic_services": {"status": "ok", "count": 80, "data": [], "error": null}, + "signed_drivers": {"status": "ok", "count": 150, "data": [], "error": null}, + "hotfixes": {"status": "ok", "count": 12, "data": [], "error": null}, + "non_microsoft_scheduled_tasks": {"status": "ok", "count": 8, "data": [], "error": null}, + "startup_programs": {"status": "ok", "count": 6, "data": [], "error": null}, + "active_tcp_listeners": {"status": "ok", "count": 15, "data": [], "error": null}, + "problem_devices": {"status": "ok", "count": 0, "data": [], "error": null}, + "firewall_profiles": { + "status": "ok", + "count": 3, + "data": [ + {"Name": "Domain", "Enabled": true, "DefaultInboundAction": "NotConfigured", "DefaultOutboundAction": "NotConfigured"}, + {"Name": "Private", "Enabled": true, "DefaultInboundAction": "NotConfigured", "DefaultOutboundAction": "NotConfigured"}, + {"Name": "Public", "Enabled": true, "DefaultInboundAction": "NotConfigured", "DefaultOutboundAction": "NotConfigured"} + ], + "error": null + }, + "defender": { + "status": "ok", + "count": 1, + "data": [ + { + "AntivirusEnabled": true, + "AntispywareEnabled": true, + "RealTimeProtectionEnabled": true, + "BehaviorMonitorEnabled": true, + "IoavProtectionEnabled": true, + "NISEnabled": true, + "AntivirusSignatureLastUpdated": "2026-09-14T12:00:00+02:00" + } + ], + "error": null + }, + "battery": {"status": "ok", "count": 0, "data": [], "error": null}, + "component_store": { + "status": "ok", + "count": 1, + "data": [ + { + "executable": "DISM.exe", + "arguments": ["/Online", "/Cleanup-Image", "/CheckHealth"], + "exit_code": 0, + "output": ["No component store corruption detected."] + } + ], + "error": null + }, + "system_file_check": { + "status": "ok", + "count": 1, + "data": [ + { + "executable": "sfc.exe", + "arguments": ["/verifyonly"], + "exit_code": 0, + "output": ["Windows Resource Protection did not find any integrity violations."] + } + ], + "error": null + }, + "recent_system_errors": { + "status": "ok", + "count": 1, + "data": [ + { + "TimeCreated": "2026-09-14T15:00:00+02:00", + "Id": 7000, + "ProviderName": "Service Control Manager", + "Message": "The TestService service failed to start due to the following error: The system cannot find the file specified." + } + ], + "error": null + }, + "recent_application_errors": {"status": "ok", "count": 0, "data": [], "error": null}, + "ip_configuration": {"status": "ok", "count": 1, "data": [], "error": null}, + "dns_servers": {"status": "ok", "count": 1, "data": [], "error": null}, + "power_plan": {"status": "ok", "count": 1, "data": [], "error": null}, + "top_processes_by_memory": {"status": "ok", "count": 30, "data": [], "error": null}, + "important_directories": {"status": "ok", "count": 1, "data": [], "error": null} + } +}