@hardkeel/quantum-scan 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/map-rank.js CHANGED
@@ -1,48 +1,48 @@
1
- // Ranks every finding by what breaks first, and turns code findings into map findings.
2
- export function tierOf(f) {
3
- if (f.risk !== "quantum-vulnerable")
4
- return 1;
5
- if ((f.primitive === "key-agreement" || f.primitive === "public-key-encryption") && f.internetFacing)
6
- return 2;
7
- if (f.primitive === "signature" && f.longLived)
8
- return 3;
9
- return 4;
10
- }
11
- const SEV = { critical: 0, high: 1, medium: 2, low: 3 };
12
- export function rank(findings) {
13
- return findings
14
- .map((f) => ({ ...f, tier: tierOf(f) }))
15
- .sort((a, b) => a.tier - b.tier || SEV[a.severity] - SEV[b.severity] || a.area.localeCompare(b.area) || a.target.localeCompare(b.target));
16
- }
17
- export function fromCodeFinding(f) {
18
- return {
19
- area: "code",
20
- target: `${f.file}:${f.line}`,
21
- ruleId: f.ruleId,
22
- title: f.title,
23
- algorithm: f.algorithm,
24
- primitive: f.primitive,
25
- risk: f.risk,
26
- severity: f.severity,
27
- fix: f.fix,
28
- internetFacing: false,
29
- keySize: f.keySize,
30
- };
31
- }
32
- /** Back to the code scanner's shape, so the CycloneDX inventory builder can be reused. */
33
- export function toFinding(f) {
34
- return {
35
- kind: f.risk === "secret" ? "secret" : f.risk === "exposed" || f.primitive === "setting" ? "config" : "crypto",
36
- ruleId: f.ruleId,
37
- title: f.title,
38
- algorithm: f.algorithm,
39
- primitive: f.primitive,
40
- risk: f.risk,
41
- severity: f.severity,
42
- file: f.target,
43
- line: 0,
44
- snippet: "",
45
- fix: f.fix,
46
- keySize: f.keySize,
47
- };
48
- }
1
+ // Ranks every finding by what breaks first, and turns code findings into map findings.
2
+ export function tierOf(f) {
3
+ if (f.risk !== "quantum-vulnerable")
4
+ return 1;
5
+ if ((f.primitive === "key-agreement" || f.primitive === "public-key-encryption") && f.internetFacing)
6
+ return 2;
7
+ if (f.primitive === "signature" && f.longLived)
8
+ return 3;
9
+ return 4;
10
+ }
11
+ const SEV = { critical: 0, high: 1, medium: 2, low: 3 };
12
+ export function rank(findings) {
13
+ return findings
14
+ .map((f) => ({ ...f, tier: tierOf(f) }))
15
+ .sort((a, b) => a.tier - b.tier || SEV[a.severity] - SEV[b.severity] || a.area.localeCompare(b.area) || a.target.localeCompare(b.target));
16
+ }
17
+ export function fromCodeFinding(f) {
18
+ return {
19
+ area: "code",
20
+ target: `${f.file}:${f.line}`,
21
+ ruleId: f.ruleId,
22
+ title: f.title,
23
+ algorithm: f.algorithm,
24
+ primitive: f.primitive,
25
+ risk: f.risk,
26
+ severity: f.severity,
27
+ fix: f.fix,
28
+ internetFacing: false,
29
+ keySize: f.keySize,
30
+ };
31
+ }
32
+ /** Back to the code scanner's shape, so the CycloneDX inventory builder can be reused. */
33
+ export function toFinding(f) {
34
+ return {
35
+ kind: f.risk === "secret" ? "secret" : f.risk === "exposed" || f.primitive === "setting" ? "config" : "crypto",
36
+ ruleId: f.ruleId,
37
+ title: f.title,
38
+ algorithm: f.algorithm,
39
+ primitive: f.primitive,
40
+ risk: f.risk,
41
+ severity: f.severity,
42
+ file: f.target,
43
+ line: 0,
44
+ snippet: "",
45
+ fix: f.fix,
46
+ keySize: f.keySize,
47
+ };
48
+ }
@@ -1,138 +1,178 @@
1
- // The encryption map report: text for the terminal, one self-contained HTML page, and JSON.
2
- // Written to the customer's own disk. Nothing here is sent anywhere.
3
- import { TIER_NOTES, TIER_TITLES } from "./map-types.js";
4
- import { toFinding } from "./map-rank.js";
5
- import { gradeSentence, readinessScore } from "./score.js";
6
- /** Post-quantum methods already in use count toward the score the same way they do in a code scan. */
7
- function strengthSignals(strengths) {
8
- return strengths.map((s) => ({ algorithm: s.algorithm, use: /DSA/.test(s.algorithm) ? "signature" : "key-establishment", file: s.target, line: 0 }));
9
- }
10
- const AREA_TITLES = { code: "Code and config", web: "Websites and public services", host: "This machine", network: "Internal network", vpn: "VPNs", cloud: "Cloud" };
11
- export function buildMapReport(results, ranked, version, now = new Date(), accepted = []) {
12
- const strengths = results.flatMap((r) => r.strengths);
13
- const counts = { 1: 0, 2: 0, 3: 0, 4: 0 };
14
- for (const f of ranked)
15
- counts[f.tier]++;
16
- return {
17
- tool: "hard-keel-quantum-scan",
18
- version,
19
- createdAt: now.toISOString(),
20
- areas: results.map((r) => ({ area: r.area, checked: r.checked.length, skipped: r.skipped, errors: r.errors.map(({ target, kind, message }) => ({ target, kind, message })) })),
21
- score: readinessScore(ranked.map(toFinding), strengthSignals(strengths)),
22
- counts,
23
- findings: ranked,
24
- strengths,
25
- accepted,
26
- };
27
- }
28
- export function mapText(r) {
29
- const out = ["Hard Keel Quantum Scan · encryption map", "", gradeSentence(r.score), ""];
30
- for (const a of r.areas) {
31
- const bits = [`${a.checked} checked`];
32
- if (a.skipped.length)
33
- bits.push(`${a.skipped.length} skipped`);
34
- if (a.errors.length)
35
- bits.push(`${a.errors.length} couldn't be checked`);
36
- out.push(` ${AREA_TITLES[a.area] ?? a.area}: ${bits.join(", ")}`);
37
- }
38
- const total = r.findings.length;
39
- out.push("", total ? `${total} finding${total === 1 ? "" : "s"}, ranked by what breaks first.` : "Nothing found in the areas checked.");
40
- for (const t of [1, 2, 3, 4]) {
41
- const list = r.findings.filter((f) => f.tier === t);
42
- if (!list.length)
43
- continue;
44
- out.push("", `${t}. ${TIER_TITLES[t]} (${list.length})`, ` ${TIER_NOTES[t]}`);
45
- for (const f of list.slice(0, 25))
46
- out.push(` ${f.target} ${f.title}`, ` ${f.fix}`);
47
- if (list.length > 25)
48
- out.push(` ...and ${list.length - 25} more in the report.`);
49
- }
50
- if (r.strengths.length) {
51
- out.push("", `Already quantum-safe (${r.strengths.length})`);
52
- for (const s of r.strengths.slice(0, 10))
53
- out.push(` ${s.target} ${s.title}`);
54
- }
55
- if (r.accepted.length) {
56
- out.push("", `Accepted as known leftovers (${r.accepted.length}), from ${".quantum-scan-ignore"}; not counted in the score`);
57
- for (const f of r.accepted.slice(0, 10))
58
- out.push(` ${f.target} ${f.title}`);
59
- }
60
- const errors = r.areas.flatMap((a) => a.errors);
61
- if (errors.length) {
62
- out.push("", "Couldn't check");
63
- for (const e of errors.slice(0, 10))
64
- out.push(` ${e.target}: ${e.message}`);
65
- if (errors.length > 10)
66
- out.push(` ...and ${errors.length - 10} more in the report.`);
67
- }
68
- const skipped = r.areas.flatMap((a) => a.skipped);
69
- if (skipped.length) {
70
- out.push("", "Skipped");
71
- for (const s of skipped.slice(0, 10))
72
- out.push(` ${s.target}: ${s.reason}`);
73
- if (skipped.length > 10)
74
- out.push(` ...and ${skipped.length - 10} more in the report.`);
75
- }
76
- return out.join("\n");
77
- }
78
- const esc = (s) => s.replace(/[&<>"']/g, (c) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" })[c]);
79
- export function mapHtml(r, activity) {
80
- const row = (f) => `<tr><td class="area">${esc(AREA_TITLES[f.area] ?? f.area)}</td><td class="mono">${esc(f.target)}</td><td>${esc(f.title)}<div class="fix">${esc(f.fix)}</div></td></tr>`;
81
- const table = (list) => `<table><thead><tr><th class="area">Area</th><th>Where</th><th>What and how to fix it</th></tr></thead><tbody>${list.map(row).join("")}</tbody></table>`;
82
- const tiers = [1, 2, 3, 4]
83
- .map((t) => {
84
- const list = r.findings.filter((f) => f.tier === t);
85
- if (!list.length)
86
- return "";
87
- return `<section><h2><span class="n">${t}</span>${esc(TIER_TITLES[t])} <span class="count">${list.length}</span></h2><p class="note">${esc(TIER_NOTES[t])}</p>${table(list)}</section>`;
88
- })
89
- .join("");
90
- const strengths = r.strengths.length
91
- ? `<section><h2>Already quantum-safe <span class="count">${r.strengths.length}</span></h2><ul>${r.strengths.map((s) => `<li><span class="mono">${esc(s.target)}</span> ${esc(s.title)}</li>`).join("")}</ul></section>`
92
- : "";
93
- const accepted = r.accepted.length
94
- ? `<section><h2>Accepted as known leftovers <span class="count">${r.accepted.length}</span></h2><p class="note">Marked in .quantum-scan-ignore. Listed here so nothing is hidden, but left out of the counts and the score.</p>${table(r.accepted)}</section>`
95
- : "";
96
- const areas = r.areas
97
- .map((a) => {
98
- const extra = [...a.skipped.map((s) => `${s.target}: ${s.reason}`), ...a.errors.map((e) => `${e.target}: couldn't check (${e.message})`)];
99
- return `<li><strong>${esc(AREA_TITLES[a.area] ?? a.area)}</strong>: ${a.checked} checked${extra.length ? `<ul>${extra.map((x) => `<li>${esc(x)}</li>`).join("")}</ul>` : ""}</li>`;
100
- })
101
- .join("");
102
- const summary = [1, 2, 3, 4].map((t) => `<div class="tile t${t}"><div class="big">${r.counts[t]}</div><div>${esc(TIER_TITLES[t])}</div></div>`).join("");
103
- const g = r.score;
104
- const gradeClass = g.grade.startsWith("A") ? "good" : g.grade === "B" ? "ok" : "bad";
105
- return `<!doctype html>
106
- <html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
107
- <meta name="color-scheme" content="light dark">
108
- <title>Encryption map · Hard Keel Quantum Scan</title>
109
- <style>
110
- :root{--bg:#ffffff;--fg:#111a21;--muted:#5b6873;--accent:#2f7d71;--line:rgba(0,0,0,.1);--bad:#b4412f;--warn:#93630f;--good:#2f7d71}
111
- @media (prefers-color-scheme:dark){:root{--bg:#0a0e12;--fg:#eef2f5;--muted:#8f9da9;--accent:#5aa99d;--line:rgba(255,255,255,.09);--bad:#e07a6a;--warn:#e0b25a;--good:#5aa99d}}
112
- @media print{:root{--bg:#fff;--fg:#000;--muted:#444;--accent:#2f7d71;--line:#ccc;--bad:#a0301f;--warn:#7a520c;--good:#2f7d71}details{display:none}section{break-inside:auto}tr{break-inside:avoid}}
113
- *{box-sizing:border-box}body{margin:0;background:var(--bg);color:var(--fg);font:15px/1.6 Inter,system-ui,-apple-system,sans-serif}
114
- main{max-width:1000px;margin:0 auto;padding:40px 20px 80px}h1{font-size:28px;margin:0}h2{font-size:18px;margin:40px 0 4px;display:flex;align-items:center;gap:10px}
115
- .eyebrow{font:12px "IBM Plex Mono",ui-monospace,monospace;letter-spacing:.3em;color:var(--accent);text-transform:uppercase}
116
- .muted,.note{color:var(--muted)}.note{margin:0 0 12px}.n{display:inline-grid;place-items:center;width:26px;height:26px;border-radius:50%;border:1px solid var(--accent);color:var(--accent);font-size:13px;flex:none}
117
- .count{color:var(--muted);font-weight:400}.tiles{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:12px;margin:20px 0 28px}
118
- .tile{border:1px solid var(--line);border-radius:10px;padding:14px}.big{font-size:28px;font-weight:600}.t1 .big{color:var(--bad)}.t2 .big{color:var(--warn)}
119
- .score{display:flex;gap:18px;align-items:center;border:1px solid var(--line);border-radius:12px;padding:16px 18px;margin-top:28px}
120
- .grade{font-size:40px;font-weight:700;line-height:1;min-width:64px;text-align:center}.grade.good{color:var(--good)}.grade.ok{color:var(--warn)}.grade.bad{color:var(--bad)}
121
- table{width:100%;border-collapse:collapse;font-size:14px}th,td{text-align:left;vertical-align:top;padding:9px 8px;border-top:1px solid var(--line)}th{color:var(--muted);font-weight:500}
122
- .mono{font-family:"IBM Plex Mono",ui-monospace,monospace;font-size:12.5px;word-break:break-all}.fix{color:var(--muted);margin-top:2px}
123
- details{margin-top:40px}pre{white-space:pre-wrap;font-size:12px;color:var(--muted)}a{color:var(--accent)}
124
- @media (max-width:640px){.area{display:none}td.mono{width:38%}h1{font-size:24px}.grade{font-size:32px;min-width:48px}}
125
- </style></head><body><main>
126
- <div class="eyebrow">Hard Keel Quantum Scan</div><h1>Encryption map</h1>
127
- <p class="muted">Created ${esc(r.createdAt.slice(0, 16).replace("T", " "))} UTC on this machine. This report stays on your computer unless you share it.</p>
128
- <div class="score"><div class="grade ${gradeClass}">${esc(g.grade)}</div><div><strong>Quantum readiness ${g.score}/100</strong><div class="muted">${esc(gradeSentence(g).replace(/^Quantum readiness: [^.]+\.\s*/, ""))} Hard Keel method v${esc(g.method)}, the same as a code scan, across every area checked.</div></div></div>
129
- <div class="tiles">${summary}</div>
130
- ${tiers || "<p>Nothing found in the areas checked.</p>"}
131
- ${strengths}
132
- ${accepted}
133
- <section><h2>What was checked</h2><ul>${areas}</ul></section>
134
- <details><summary>Activity log (${activity.length} entries)</summary><pre>${esc(activity.join("\n"))}</pre></details>
135
- <p class="muted" style="margin-top:40px">Look-only checks: normal connections and local settings. No logins, changes or attack traffic. <a href="https://hardkeel.com/quantum-scan/">hardkeel.com</a></p>
136
- </main></body></html>
137
- `;
138
- }
1
+ // The encryption map report: text for the terminal, one self-contained HTML page, and JSON.
2
+ // Written to the customer's own disk. Nothing here is sent anywhere.
3
+ import { TIER_NOTES, TIER_TITLES } from "./map-types.js";
4
+ import { toFinding } from "./map-rank.js";
5
+ import { gradeSentence, readinessScore } from "./score.js";
6
+ /** Post-quantum methods already in use count toward the score the same way they do in a code scan. */
7
+ function strengthSignals(strengths) {
8
+ return strengths.map((s) => ({ algorithm: s.algorithm, use: /DSA/.test(s.algorithm) ? "signature" : "key-establishment", file: s.target, line: 0 }));
9
+ }
10
+ const AREA_TITLES = { code: "Code and config", web: "Websites and public services", host: "This machine", network: "Network and equipment", vpn: "VPNs", cloud: "Cloud" };
11
+ export function buildMapReport(results, ranked, version, now = new Date(), accepted = [], extras = { cloudKeys: [], people: null }) {
12
+ const strengths = results.flatMap((r) => r.strengths);
13
+ const counts = { 1: 0, 2: 0, 3: 0, 4: 0 };
14
+ for (const f of ranked)
15
+ counts[f.tier]++;
16
+ return {
17
+ tool: "hard-keel-quantum-scan",
18
+ version,
19
+ createdAt: now.toISOString(),
20
+ areas: results.map((r) => ({ area: r.area, checked: r.checked.length, skipped: r.skipped, errors: r.errors.map(({ target, kind, message }) => ({ target, kind, message })) })),
21
+ score: readinessScore(ranked.map(toFinding), strengthSignals(strengths)),
22
+ counts,
23
+ findings: ranked,
24
+ strengths,
25
+ accepted,
26
+ cloudKeys: extras.cloudKeys,
27
+ people: extras.people,
28
+ };
29
+ }
30
+ export function peopleSentence(p) {
31
+ return `People and process: ${p.inPlace} of ${p.answered} in place (${p.score}/100), answered ${p.answeredAt}.`;
32
+ }
33
+ const custodyCount = (r, c) => r.cloudKeys.filter((a) => a.custody === c).length;
34
+ /** A grade only means something when at least one place was actually checked. */
35
+ export const nothingChecked = (r) => !r.areas.some((a) => a.checked > 0) && !r.findings.length && !r.strengths.length;
36
+ const NOT_GRADED = "Quantum readiness: not graded, because nothing was checked.";
37
+ export function mapText(r) {
38
+ const out = ["Hard Keel Quantum Scan · encryption map", "", nothingChecked(r) ? NOT_GRADED : gradeSentence(r.score)];
39
+ if (r.people)
40
+ out.push(peopleSentence(r.people));
41
+ if (r.areas.length)
42
+ out.push("");
43
+ for (const a of r.areas) {
44
+ const bits = [`${a.checked} checked`];
45
+ if (a.skipped.length)
46
+ bits.push(`${a.skipped.length} skipped`);
47
+ if (a.errors.length)
48
+ bits.push(`${a.errors.length} couldn't be checked`);
49
+ out.push(` ${AREA_TITLES[a.area] ?? a.area}: ${bits.join(", ")}`);
50
+ }
51
+ const total = r.findings.length;
52
+ out.push("", total ? `${total} finding${total === 1 ? "" : "s"}, ranked by what breaks first.` : nothingChecked(r) ? "No scan areas were checked this time." : "Nothing found in the areas checked.");
53
+ for (const t of [1, 2, 3, 4]) {
54
+ const list = r.findings.filter((f) => f.tier === t);
55
+ if (!list.length)
56
+ continue;
57
+ out.push("", `${t}. ${TIER_TITLES[t]} (${list.length})`, ` ${TIER_NOTES[t]}`);
58
+ for (const f of list.slice(0, 25))
59
+ out.push(` ${f.target} ${f.title}`, ` ${f.fix}`);
60
+ if (list.length > 25)
61
+ out.push(` ...and ${list.length - 25} more in the report.`);
62
+ }
63
+ if (r.strengths.length) {
64
+ out.push("", `Already quantum-safe (${r.strengths.length})`);
65
+ for (const s of r.strengths.slice(0, 10))
66
+ out.push(` ${s.target} ${s.title}`);
67
+ }
68
+ if (r.cloudKeys.length) {
69
+ const prov = custodyCount(r, "provider");
70
+ out.push("", `Who can read your cloud data (${r.cloudKeys.length}), advice, not scored`);
71
+ out.push(` ${prov} with keys the provider holds, ${r.cloudKeys.length - prov} with keys in the provider's key service.`);
72
+ for (const a of r.cloudKeys.slice(0, 10))
73
+ out.push(` ${a.target} ${a.resource}: ${a.title}`);
74
+ if (r.cloudKeys.length > 10)
75
+ out.push(` ...and ${r.cloudKeys.length - 10} more in the report.`);
76
+ out.push(` ${r.cloudKeys.find((a) => a.custody === "provider")?.fix ?? r.cloudKeys[0].fix}`);
77
+ }
78
+ if (r.people?.gaps.length) {
79
+ out.push("", `People and process gaps (${r.people.gaps.length})`);
80
+ for (const g of r.people.gaps.slice(0, 12))
81
+ out.push(` ${g.answer === "no" ? "No" : "Not sure"}: ${g.question}`, ` ${g.fix}`);
82
+ }
83
+ if (r.accepted.length) {
84
+ out.push("", `Accepted as known leftovers (${r.accepted.length}), from ${".quantum-scan-ignore"}; not counted in the score`);
85
+ for (const f of r.accepted.slice(0, 10))
86
+ out.push(` ${f.target} ${f.title}`);
87
+ }
88
+ const errors = r.areas.flatMap((a) => a.errors);
89
+ if (errors.length) {
90
+ out.push("", "Couldn't check");
91
+ for (const e of errors.slice(0, 10))
92
+ out.push(` ${e.target}: ${e.message}`);
93
+ if (errors.length > 10)
94
+ out.push(` ...and ${errors.length - 10} more in the report.`);
95
+ }
96
+ const skipped = r.areas.flatMap((a) => a.skipped);
97
+ if (skipped.length) {
98
+ out.push("", "Skipped");
99
+ for (const s of skipped.slice(0, 10))
100
+ out.push(` ${s.target}: ${s.reason}`);
101
+ if (skipped.length > 10)
102
+ out.push(` ...and ${skipped.length - 10} more in the report.`);
103
+ }
104
+ return out.join("\n");
105
+ }
106
+ const esc = (s) => s.replace(/[&<>"']/g, (c) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" })[c]);
107
+ export function mapHtml(r, activity) {
108
+ const row = (f) => `<tr><td class="area">${esc(AREA_TITLES[f.area] ?? f.area)}</td><td class="mono">${esc(f.target)}</td><td>${esc(f.title)}<div class="fix">${esc(f.fix)}</div></td></tr>`;
109
+ const table = (list) => `<table><thead><tr><th class="area">Area</th><th>Where</th><th>What and how to fix it</th></tr></thead><tbody>${list.map(row).join("")}</tbody></table>`;
110
+ const tiers = [1, 2, 3, 4]
111
+ .map((t) => {
112
+ const list = r.findings.filter((f) => f.tier === t);
113
+ if (!list.length)
114
+ return "";
115
+ return `<section><h2><span class="n">${t}</span>${esc(TIER_TITLES[t])} <span class="count">${list.length}</span></h2><p class="note">${esc(TIER_NOTES[t])}</p>${table(list)}</section>`;
116
+ })
117
+ .join("");
118
+ const strengths = r.strengths.length
119
+ ? `<section><h2>Already quantum-safe <span class="count">${r.strengths.length}</span></h2><ul>${r.strengths.map((s) => `<li><span class="mono">${esc(s.target)}</span> ${esc(s.title)}</li>`).join("")}</ul></section>`
120
+ : "";
121
+ const accepted = r.accepted.length
122
+ ? `<section><h2>Accepted as known leftovers <span class="count">${r.accepted.length}</span></h2><p class="note">Marked in .quantum-scan-ignore. Listed here so nothing is hidden, but left out of the counts and the score.</p>${table(r.accepted)}</section>`
123
+ : "";
124
+ const cloud = r.cloudKeys.length
125
+ ? `<section><h2>Who can read your cloud data <span class="count">${r.cloudKeys.length}</span></h2><p class="note">Advice, not scored. Keys held by a cloud provider protect against a stolen disk, not against the provider, someone working there, or a legal demand made to them. ${custodyCount(r, "provider")} ${custodyCount(r, "provider") === 1 ? "uses" : "use"} keys the provider holds; ${custodyCount(r, "provider-kms")} ${custodyCount(r, "provider-kms") === 1 ? "uses" : "use"} keys in the provider's key service.</p><table><thead><tr><th>Where</th><th>What and how to fix it</th></tr></thead><tbody>${r.cloudKeys.map((a) => `<tr><td class="mono">${esc(a.target)}<div class="fix">${esc(a.resource)}</div></td><td>${esc(a.title)}<div class="fix">${esc(a.fix)}</div></td></tr>`).join("")}</tbody></table></section>`
126
+ : "";
127
+ const p = r.people;
128
+ const people = p
129
+ ? `<section><h2>People and process <span class="count">${p.inPlace} of ${p.answered} in place</span></h2><p class="note">Your own answers from ${esc(p.answeredAt)}, scored on their own. They stay on this machine and are never shared.</p>${p.gaps.length
130
+ ? `<table><thead><tr><th class="area">Group</th><th>Answer</th><th>Question and what to do</th></tr></thead><tbody>${p.gaps.map((g) => `<tr><td class="area">${esc(g.group)}</td><td>${g.answer === "no" ? "No" : "Not sure"}</td><td>${esc(g.question)}<div class="fix">${esc(g.fix)}</div></td></tr>`).join("")}</tbody></table>`
131
+ : "<p>Everything you answered is in place.</p>"}</section>`
132
+ : "";
133
+ const areas = r.areas
134
+ .map((a) => {
135
+ const extra = [...a.skipped.map((s) => `${s.target}: ${s.reason}`), ...a.errors.map((e) => `${e.target}: couldn't check (${e.message})`)];
136
+ return `<li><strong>${esc(AREA_TITLES[a.area] ?? a.area)}</strong>: ${a.checked} checked${extra.length ? `<ul>${extra.map((x) => `<li>${esc(x)}</li>`).join("")}</ul>` : ""}</li>`;
137
+ })
138
+ .join("");
139
+ const summary = [1, 2, 3, 4].map((t) => `<div class="tile t${t}"><div class="big">${r.counts[t]}</div><div>${esc(TIER_TITLES[t])}</div></div>`).join("");
140
+ const g = r.score;
141
+ const gradeClass = g.grade.startsWith("A") ? "good" : g.grade === "B" ? "ok" : "bad";
142
+ return `<!doctype html>
143
+ <html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
144
+ <meta name="color-scheme" content="light dark">
145
+ <title>Encryption map · Hard Keel Quantum Scan</title>
146
+ <style>
147
+ :root{--bg:#ffffff;--fg:#111a21;--muted:#5b6873;--accent:#2f7d71;--line:rgba(0,0,0,.1);--bad:#b4412f;--warn:#93630f;--good:#2f7d71}
148
+ @media (prefers-color-scheme:dark){:root{--bg:#0a0e12;--fg:#eef2f5;--muted:#8f9da9;--accent:#5aa99d;--line:rgba(255,255,255,.09);--bad:#e07a6a;--warn:#e0b25a;--good:#5aa99d}}
149
+ @media print{:root{--bg:#fff;--fg:#000;--muted:#444;--accent:#2f7d71;--line:#ccc;--bad:#a0301f;--warn:#7a520c;--good:#2f7d71}details{display:none}section{break-inside:auto}tr{break-inside:avoid}}
150
+ *{box-sizing:border-box}body{margin:0;background:var(--bg);color:var(--fg);font:15px/1.6 Inter,system-ui,-apple-system,sans-serif}
151
+ main{max-width:1000px;margin:0 auto;padding:40px 20px 80px}h1{font-size:28px;margin:0}h2{font-size:18px;margin:40px 0 4px;display:flex;align-items:center;gap:10px}
152
+ .eyebrow{font:12px "IBM Plex Mono",ui-monospace,monospace;letter-spacing:.3em;color:var(--accent);text-transform:uppercase}
153
+ .muted,.note{color:var(--muted)}.note{margin:0 0 12px}.n{display:inline-grid;place-items:center;width:26px;height:26px;border-radius:50%;border:1px solid var(--accent);color:var(--accent);font-size:13px;flex:none}
154
+ .count{color:var(--muted);font-weight:400}.tiles{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:12px;margin:20px 0 28px}
155
+ .tile{border:1px solid var(--line);border-radius:10px;padding:14px}.big{font-size:28px;font-weight:600}.t1 .big{color:var(--bad)}.t2 .big{color:var(--warn)}
156
+ .score{display:flex;gap:18px;align-items:center;border:1px solid var(--line);border-radius:12px;padding:16px 18px;margin-top:28px}
157
+ .grade{font-size:40px;font-weight:700;line-height:1;min-width:64px;text-align:center}.grade.good{color:var(--good)}.grade.ok{color:var(--warn)}.grade.bad{color:var(--bad)}
158
+ table{width:100%;border-collapse:collapse;font-size:14px}th,td{text-align:left;vertical-align:top;padding:9px 8px;border-top:1px solid var(--line)}th{color:var(--muted);font-weight:500}
159
+ .mono{font-family:"IBM Plex Mono",ui-monospace,monospace;font-size:12.5px;word-break:break-all}.fix{color:var(--muted);margin-top:2px}
160
+ details{margin-top:40px}pre{white-space:pre-wrap;font-size:12px;color:var(--muted)}a{color:var(--accent)}
161
+ @media (max-width:640px){.area{display:none}td.mono{width:38%}h1{font-size:24px}.grade{font-size:32px;min-width:48px}}
162
+ </style></head><body><main>
163
+ <div class="eyebrow">Hard Keel Quantum Scan</div><h1>Encryption map</h1>
164
+ <p class="muted">Created ${esc(r.createdAt.slice(0, 16).replace("T", " "))} UTC on this machine. This report stays on your computer unless you share it.</p>
165
+ ${nothingChecked(r) ? `<div class="score"><div class="grade">–</div><div><strong>Quantum readiness not graded</strong><div class="muted">Nothing was checked, so there is nothing to grade.</div></div></div>` : `<div class="score"><div class="grade ${gradeClass}">${esc(g.grade)}</div><div><strong>Quantum readiness ${g.score}/100</strong><div class="muted">${esc(gradeSentence(g).replace(/^Quantum readiness: [^.]+\.\s*/, ""))} Hard Keel method v${esc(g.method)}, the same as a code scan, across every area checked.</div></div></div>`}
166
+ ${p ? `<div class="score"><div class="grade ${p.score >= 90 ? "good" : p.score >= 60 ? "ok" : "bad"}">${p.score}</div><div><strong>People and process ${p.inPlace} of ${p.answered} in place</strong><div class="muted">From your answers to the checklist, scored on their own. Phishing, accounts, equipment, separation, data and what happens on a bad day.</div></div></div>` : ""}
167
+ <div class="tiles">${summary}</div>
168
+ ${tiers || "<p>Nothing found in the areas checked.</p>"}
169
+ ${strengths}
170
+ ${cloud}
171
+ ${people}
172
+ ${accepted}
173
+ <section><h2>What was checked</h2><ul>${areas}</ul></section>
174
+ <details><summary>Activity log (${activity.length} entries)</summary><pre>${esc(activity.join("\n"))}</pre></details>
175
+ <p class="muted" style="margin-top:40px">Look-only checks: normal connections and local settings. No logins, changes or attack traffic. <a href="https://hardkeel.com/quantum-scan/">hardkeel.com</a></p>
176
+ </main></body></html>
177
+ `;
178
+ }