Repository navigation
Expand file tree
/
Copy pathindex.html
More file actions
630 lines (597 loc) · 29.7 KB
/
Copy pathindex.html
File metadata and controls
630 lines (597 loc) · 29.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="color-scheme" content="light dark">
<meta name="description" content="Explore recent changes to CISA's Known Exploited Vulnerabilities catalog.">
<title>KEV Change Log</title>
<style>
:root {
color-scheme: light;
--canvas: #f4f6f8;
--surface: #ffffff;
--surface-2: #f8fafb;
--ink: #16212d;
--muted: #5c6976;
--faint: #87929c;
--line: #dbe1e6;
--line-strong: #c8d0d8;
--navy: #12365b;
--blue: #1261a6;
--blue-soft: #eaf3fb;
--green: #08783e;
--green-soft: #e8f6ee;
--red: #b42318;
--red-soft: #fcede9;
--purple: #6e3cb1;
--purple-soft: #f2ecfa;
--amber: #895b08;
--amber-soft: #fbf1d8;
--shadow: 0 1px 2px rgba(10, 30, 50, .04), 0 8px 24px rgba(10, 30, 50, .06);
--radius: 14px;
}
:root[data-theme="dark"] {
color-scheme: dark;
--canvas: #0e151d;
--surface: #151f29;
--surface-2: #192530;
--ink: #edf3f7;
--muted: #a7b3bd;
--faint: #7f8d99;
--line: #2a3946;
--line-strong: #3a4b59;
--navy: #dceefe;
--blue: #72b8f3;
--blue-soft: #17334b;
--green: #6ed89d;
--green-soft: #163b2a;
--red: #ff948a;
--red-soft: #49231f;
--purple: #c6a2f5;
--purple-soft: #382650;
--amber: #efc46d;
--amber-soft: #41351c;
--shadow: 0 1px 2px rgba(0, 0, 0, .25), 0 12px 28px rgba(0, 0, 0, .18);
}
* { box-sizing: border-box; }
html { min-width: 320px; background: var(--canvas); }
body {
margin: 0;
min-height: 100vh;
background: var(--canvas);
color: var(--ink);
font: 14px/1.5 ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
-webkit-font-smoothing: antialiased;
}
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: var(--blue); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--blue) 45%, transparent); outline-offset: 2px; }
.topbar {
background: var(--navy);
color: #fff;
}
:root[data-theme="dark"] .topbar { background: #101c27; border-bottom: 1px solid var(--line); }
.topbar-inner, main, .footer-inner { width: min(1180px, calc(100% - 40px)); margin: 0 auto; }
.topbar-inner {
min-height: 68px;
display: flex;
align-items: center;
justify-content: space-between;
gap: 20px;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark {
width: 34px;
height: 39px;
display: grid;
place-items: center;
flex: 0 0 auto;
color: #12365b;
background: #fff;
font-size: 10px;
font-weight: 900;
letter-spacing: -.03em;
clip-path: polygon(50% 0, 96% 16%, 88% 73%, 50% 100%, 12% 73%, 4% 16%);
}
.brand-name { font-size: 15px; font-weight: 760; letter-spacing: .01em; white-space: nowrap; }
.brand-meta { opacity: .68; font-size: 12px; white-space: nowrap; }
.icon-button {
width: 38px;
height: 38px;
border: 1px solid rgba(255,255,255,.28);
border-radius: 10px;
color: #fff;
background: rgba(255,255,255,.08);
cursor: pointer;
}
.icon-button:hover { background: rgba(255,255,255,.15); }
main { padding: 42px 0 56px; }
.intro { display: flex; justify-content: space-between; align-items: end; gap: 32px; margin-bottom: 24px; }
.eyebrow { margin: 0 0 7px; color: var(--blue); font-size: 12px; font-weight: 800; letter-spacing: .11em; text-transform: uppercase; }
h1 { margin: 0; color: var(--navy); font-size: clamp(30px, 4vw, 44px); line-height: 1.08; letter-spacing: -.035em; }
.lede { max-width: 680px; margin: 12px 0 0; color: var(--muted); font-size: 15px; }
.source-link { flex: 0 0 auto; font-weight: 700; text-decoration: none; }
.source-link:hover { text-decoration: underline; }
.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 18px; }
.metric {
min-height: 92px;
padding: 17px 18px;
border: 1px solid var(--line);
border-radius: 12px;
background: var(--surface);
box-shadow: 0 1px 2px rgba(10,30,50,.025);
}
.metric-label { display: block; color: var(--muted); font-size: 12px; font-weight: 700; }
.metric-value { display: block; margin-top: 5px; color: var(--navy); font-size: 24px; font-weight: 780; letter-spacing: -.03em; }
.metric-value.small { padding-top: 4px; font-size: 16px; letter-spacing: -.01em; }
.panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.filters { display: grid; grid-template-columns: auto 1fr auto; gap: 18px; align-items: end; padding: 17px 18px; margin-bottom: 18px; }
.field-row { display: flex; gap: 10px; align-items: end; }
label { display: grid; gap: 5px; color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
input[type="date"], input[type="search"] {
height: 40px;
border: 1px solid var(--line-strong);
border-radius: 9px;
background: var(--surface-2);
color: var(--ink);
padding: 0 11px;
}
input[type="search"] { width: 100%; min-width: 180px; }
.presets { display: flex; gap: 4px; padding: 3px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); }
.preset, .button {
min-height: 34px;
border: 0;
border-radius: 7px;
cursor: pointer;
font-weight: 740;
}
.preset { padding: 0 12px; color: var(--muted); background: transparent; }
.preset:hover { color: var(--ink); }
.preset[aria-pressed="true"] { color: var(--blue); background: var(--surface); box-shadow: 0 1px 4px rgba(10,30,50,.10); }
.button { height: 40px; padding: 0 17px; color: #fff; background: var(--blue); }
.button:hover { filter: brightness(.94); }
.button:disabled { opacity: .55; cursor: wait; }
.timeline-head { min-height: 66px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 13px 18px; border-bottom: 1px solid var(--line); }
h2 { margin: 0; color: var(--navy); font-size: 17px; letter-spacing: -.01em; }
.status { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.status[data-kind="error"] { color: var(--red); }
.search-wrap { width: min(300px, 40%); }
.loading { padding: 42px 20px; text-align: center; color: var(--muted); }
.spinner { width: 24px; height: 24px; margin: 0 auto 10px; border: 3px solid var(--line); border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 1.8s; } }
.commit-list { list-style: none; margin: 0; padding: 0; }
.commit { display: grid; grid-template-columns: 166px minmax(0, 1fr); border-bottom: 1px solid var(--line); }
.commit:last-child { border-bottom: 0; }
.commit-time { padding: 20px 18px; border-right: 1px solid var(--line); background: var(--surface-2); }
.commit-time time { display: block; color: var(--ink); font-weight: 750; }
.commit-time span { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; }
.commit-body { min-width: 0; padding: 17px 20px 18px; }
.commit-top { display: flex; justify-content: space-between; gap: 16px; align-items: start; }
.commit-title { margin: 0; font-size: 14px; font-weight: 720; }
.commit-title a { color: var(--ink); text-decoration: none; }
.commit-title a:hover { color: var(--blue); text-decoration: underline; }
.sha { color: var(--faint); font: 12px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.badge { display: inline-flex; align-items: center; min-height: 25px; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 780; }
.badge.added { color: var(--green); background: var(--green-soft); }
.badge.removed { color: var(--red); background: var(--red-soft); }
.badge.ransom { color: var(--purple); background: var(--purple-soft); }
.badge.admin { color: var(--amber); background: var(--amber-soft); }
.badge.file { color: var(--blue); background: var(--blue-soft); }
details { margin-top: 13px; }
summary { width: fit-content; color: var(--blue); cursor: pointer; font-size: 12px; font-weight: 730; }
.changes { display: grid; gap: 7px; margin: 11px 0 0; padding: 0; list-style: none; }
.change { padding: 9px 11px; border-left: 3px solid var(--line-strong); border-radius: 0 7px 7px 0; background: var(--surface-2); overflow-wrap: anywhere; }
.change.added { border-left-color: var(--green); }
.change.removed { border-left-color: var(--red); }
.change.ransom { border-left-color: var(--purple); }
.cve { margin-right: 6px; color: var(--ink); font: 700 12px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; }
.change-copy { color: var(--muted); font-size: 12px; }
.empty { padding: 44px 20px; text-align: center; color: var(--muted); }
footer { border-top: 1px solid var(--line); color: var(--muted); background: var(--surface); }
.footer-inner { min-height: 74px; display: flex; align-items: center; justify-content: space-between; gap: 20px; font-size: 12px; }
.footer-inner p { margin: 0; }
@media (max-width: 820px) {
.metrics { grid-template-columns: repeat(2, 1fr); }
.filters { grid-template-columns: 1fr; align-items: stretch; }
.field-row { justify-content: space-between; }
.field-row label { flex: 1; }
input[type="date"] { width: 100%; }
.presets { justify-self: start; }
.button { width: 100%; }
}
@media (max-width: 620px) {
.topbar-inner, main, .footer-inner { width: min(100% - 24px, 1180px); }
.brand-meta, .source-link { display: none; }
main { padding-top: 28px; }
.intro { margin-bottom: 20px; }
.metrics { gap: 8px; }
.metric { min-height: 80px; padding: 13px 14px; }
.metric-value { font-size: 21px; }
.metric-value.small { font-size: 14px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; }
.timeline-head { align-items: stretch; flex-direction: column; }
.search-wrap { width: 100%; }
.commit { grid-template-columns: 1fr; }
.commit-time { display: flex; gap: 7px; align-items: baseline; padding: 12px 16px; border-right: 0; border-bottom: 1px solid var(--line); }
.commit-time span { margin: 0; }
.commit-body { padding: 15px 16px 17px; }
.footer-inner { align-items: flex-start; flex-direction: column; justify-content: center; padding: 16px 0; gap: 5px; }
}
</style>
</head>
<body>
<header class="topbar">
<div class="topbar-inner">
<div class="brand">
<div class="brand-mark" aria-hidden="true">KEV</div>
<div>
<div class="brand-name">Known Exploited Vulnerabilities</div>
<div class="brand-meta">Change intelligence from CISA’s public catalog</div>
</div>
</div>
<button class="icon-button" id="themeToggle" type="button" aria-label="Use dark theme" title="Change theme">☾</button>
</div>
</header>
<main>
<section class="intro" aria-labelledby="pageTitle">
<div>
<p class="eyebrow">Catalog activity</p>
<h1 id="pageTitle">KEV change log</h1>
<p class="lede">See what entered, left, or changed in the catalog—without comparing raw files by hand.</p>
</div>
<a class="source-link" href="https://github.com/cisagov/kev-data" target="_blank" rel="noopener noreferrer">View source on GitHub ↗</a>
</section>
<section class="metrics" aria-label="Change summary">
<div class="metric"><span class="metric-label">Commits</span><strong class="metric-value" id="metricCommits">—</strong></div>
<div class="metric"><span class="metric-label">CVEs added</span><strong class="metric-value" id="metricAdded">—</strong></div>
<div class="metric"><span class="metric-label">Field changes</span><strong class="metric-value" id="metricChanged">—</strong></div>
<div class="metric"><span class="metric-label">Latest activity</span><strong class="metric-value small" id="metricLatest">—</strong></div>
</section>
<section class="panel filters" aria-label="Date range filters">
<div class="field-row">
<label>From <input id="fromDate" type="date"></label>
<label>To <input id="toDate" type="date"></label>
</div>
<div class="presets" aria-label="Quick date ranges">
<button class="preset" type="button" data-days="14" aria-pressed="true">14 days</button>
<button class="preset" type="button" data-days="30" aria-pressed="false">30 days</button>
<button class="preset" type="button" data-days="90" aria-pressed="false">90 days</button>
</div>
<button class="button" id="applyRange" type="button">Update timeline</button>
</section>
<section class="panel" aria-labelledby="timelineTitle">
<div class="timeline-head">
<div>
<h2 id="timelineTitle">Catalog updates</h2>
<p class="status" id="status" role="status" aria-live="polite">Preparing timeline…</p>
</div>
<div class="search-wrap">
<input id="search" type="search" placeholder="Filter by CVE or field…" aria-label="Filter timeline by CVE or field" disabled>
</div>
</div>
<div id="timeline" aria-busy="true">
<div class="loading"><div class="spinner" aria-hidden="true"></div>Loading catalog activity…</div>
</div>
</section>
</main>
<footer>
<div class="footer-inner">
<p>Data is loaded directly from the public <a href="https://github.com/cisagov/kev-data" target="_blank" rel="noopener noreferrer">CISA KEV repository</a>.</p>
<p id="refreshed">Not yet refreshed</p>
</div>
</footer>
<script>
"use strict";
const REPO = "https://api.github.com/repos/cisagov/kev-data";
const RAW = "https://raw.githubusercontent.com/cisagov/kev-data";
const FILES = {
json: "known_exploited_vulnerabilities.json",
csv: "known_exploited_vulnerabilities.csv"
};
const DAY = 86_400_000;
const memoryCache = new Map();
let rows = [];
let activeLoad = 0;
const $ = id => document.getElementById(id);
const els = {
from: $("fromDate"), to: $("toDate"), apply: $("applyRange"), search: $("search"),
timeline: $("timeline"), status: $("status"), refreshed: $("refreshed"),
commits: $("metricCommits"), added: $("metricAdded"), changed: $("metricChanged"), latest: $("metricLatest")
};
function localISO(date) {
const d = new Date(date.getTime() - date.getTimezoneOffset() * 60_000);
return d.toISOString().slice(0, 10);
}
function rangeFor(days) {
const to = new Date();
to.setHours(0, 0, 0, 0);
return { from: new Date(to.getTime() - (days - 1) * DAY), to };
}
function readRange() {
const from = new Date(`${els.from.value}T00:00:00`);
const to = new Date(`${els.to.value}T23:59:59.999`);
if (!Number.isFinite(from.getTime()) || !Number.isFinite(to.getTime())) throw new Error("Choose a valid start and end date.");
if (from > to) throw new Error("The start date must be before the end date.");
if ((to - from) / DAY > 3650) throw new Error("Choose a range of 10 years or less.");
return { from, to };
}
async function fetchJSON(url) {
const response = await fetch(url, { headers: { Accept: "application/vnd.github+json" } });
if (!response.ok) throw new Error(response.status === 403 ? "GitHub’s request limit was reached. Please try again shortly." : `GitHub returned ${response.status}.`);
return response.json();
}
async function fetchText(url) {
if (!memoryCache.has(url)) {
memoryCache.set(url, fetch(url).then(response => {
if (!response.ok) throw new Error(`A catalog snapshot returned ${response.status}.`);
return response.text();
}).catch(error => { memoryCache.delete(url); throw error; }));
}
return memoryCache.get(url);
}
async function historyFor(path, oldestDate) {
const all = [];
for (let page = 1; page <= 10; page++) {
const batch = await fetchJSON(`${REPO}/commits?path=${encodeURIComponent(path)}&per_page=100&page=${page}`);
if (!batch.length) break;
all.push(...batch);
const oldest = new Date(batch.at(-1).commit.author?.date || batch.at(-1).commit.committer?.date);
if (oldest < oldestDate || batch.length < 100) break;
}
return all;
}
function parseJSON(text) {
const parsed = JSON.parse(text);
const data = Array.isArray(parsed) ? parsed : parsed.vulnerabilities || [];
return new Map(data.filter(item => item.cveID).map(item => [String(item.cveID), item]));
}
function parseCSV(text) {
const table = [];
let row = [], field = "", quoted = false;
for (let i = 0; i < text.length; i++) {
const char = text[i];
if (quoted) {
if (char === '"' && text[i + 1] === '"') { field += '"'; i++; }
else if (char === '"') quoted = false;
else field += char;
} else if (char === '"') quoted = true;
else if (char === ",") { row.push(field); field = ""; }
else if (char === "\n") { row.push(field); table.push(row); row = []; field = ""; }
else if (char !== "\r") field += char;
}
if (field || row.length) { row.push(field); table.push(row); }
const headers = table.shift() || [];
const result = new Map();
for (const cells of table) {
const record = Object.fromEntries(headers.map((key, index) => [key.trim(), (cells[index] || "").trim()]));
const id = record.cveID || record.cveId || record.CVE;
if (id) result.set(String(id), record);
}
return result;
}
function stable(value) {
if (value == null) return null;
if (typeof value === "string") return value.trim().replace(/\s+/g, " ") || null;
if (Array.isArray(value)) return value.map(stable).sort((a, b) => String(a).localeCompare(String(b)));
if (typeof value === "object") return Object.fromEntries(Object.keys(value).sort().map(key => [key, stable(value[key])]));
return value;
}
function same(a, b) { return JSON.stringify(stable(a)) === JSON.stringify(stable(b)); }
function display(value) {
if (value == null || value === "") return "empty";
if (typeof value === "object") return JSON.stringify(value);
return String(value);
}
function ransom(value) {
const normalized = String(value || "").trim().toLowerCase();
return normalized === "known" ? "Known" : normalized === "unknown" ? "Unknown" : "empty";
}
function diff(current, previous) {
const changes = [];
const ids = new Set([...current.keys(), ...previous.keys()]);
for (const id of ids) {
const now = current.get(id), before = previous.get(id);
if (now && !before) { changes.push({ id, type: "added", copy: "Added to the catalog" }); continue; }
if (!now && before) { changes.push({ id, type: "removed", copy: "Removed from the catalog" }); continue; }
const nowRansom = ransom(now.knownRansomwareCampaignUse);
const beforeRansom = ransom(before.knownRansomwareCampaignUse);
if (nowRansom !== beforeRansom) changes.push({ id, type: "ransom", copy: `Ransomware use: ${beforeRansom} → ${nowRansom}` });
const keys = new Set([...Object.keys(now), ...Object.keys(before)]);
for (const field of keys) {
if (["cveID", "cveId", "cve", "CVE", "knownRansomwareCampaignUse"].includes(field)) continue;
if (!same(now[field], before[field])) changes.push({ id, type: "admin", copy: `${field}: ${display(before[field])} → ${display(now[field])}` });
}
}
return changes;
}
function mergeHistories(jsonHistory, csvHistory) {
const merged = new Map();
const add = (commit, format) => {
if (!merged.has(commit.sha)) merged.set(commit.sha, {
sha: commit.sha,
time: commit.commit.author?.date || commit.commit.committer?.date,
url: commit.html_url,
message: (commit.commit.message || "Catalog update").split("\n")[0],
formats: new Set()
});
merged.get(commit.sha).formats.add(format);
};
jsonHistory.forEach(commit => add(commit, "json"));
csvHistory.forEach(commit => add(commit, "csv"));
return [...merged.values()].sort((a, b) => new Date(b.time) - new Date(a.time));
}
function previousSha(history, sha) {
const index = history.findIndex(commit => commit.sha === sha);
return index >= 0 ? history[index + 1]?.sha : null;
}
async function mapLimited(items, limit, worker, onProgress) {
const results = new Array(items.length);
let cursor = 0, completed = 0;
async function run() {
while (cursor < items.length) {
const index = cursor++;
results[index] = await worker(items[index], index);
onProgress?.(++completed, items.length);
}
}
await Promise.all(Array.from({ length: Math.min(limit, items.length) }, run));
return results;
}
function node(tag, className, text) {
const element = document.createElement(tag);
if (className) element.className = className;
if (text != null) element.textContent = text;
return element;
}
function badge(type, text) { return node("span", `badge ${type}`, text); }
function counts(changes) {
return changes.reduce((acc, item) => ((acc[item.type] = (acc[item.type] || 0) + 1), acc), {});
}
function renderCommit(row) {
const li = node("li", "commit");
li.dataset.search = row.changes.map(change => `${change.id} ${change.copy}`).join(" ").toLowerCase();
const date = new Date(row.time);
const timeBox = node("div", "commit-time");
const time = node("time", "", date.toLocaleDateString(undefined, { month: "short", day: "numeric", year: "numeric" }));
time.dateTime = row.time;
timeBox.append(time, node("span", "", date.toLocaleTimeString(undefined, { hour: "numeric", minute: "2-digit" })));
const body = node("div", "commit-body");
const top = node("div", "commit-top");
const title = node("p", "commit-title");
const link = node("a", "", row.message);
link.href = row.url; link.target = "_blank"; link.rel = "noopener noreferrer";
title.append(link);
top.append(title, node("span", "sha", row.sha.slice(0, 7)));
const badges = node("div", "badges");
for (const format of row.formats) badges.append(badge("file", format.toUpperCase()));
const summary = counts(row.changes);
if (summary.added) badges.append(badge("added", `${summary.added} added`));
if (summary.removed) badges.append(badge("removed", `${summary.removed} removed`));
if (summary.ransom) badges.append(badge("ransom", `${summary.ransom} ransomware`));
if (summary.admin) badges.append(badge("admin", `${summary.admin} field ${summary.admin === 1 ? "change" : "changes"}`));
body.append(top, badges);
if (row.changes.length) {
const details = document.createElement("details");
const summaryEl = document.createElement("summary");
summaryEl.textContent = `Review ${row.changes.length} ${row.changes.length === 1 ? "change" : "changes"}`;
const list = node("ul", "changes");
for (const change of row.changes) {
const item = node("li", `change ${change.type}`);
item.append(node("span", "cve", change.id), node("span", "change-copy", change.copy));
list.append(item);
}
details.append(summaryEl, list); body.append(details);
}
li.append(timeBox, body);
return li;
}
function render(filter = "") {
const query = filter.trim().toLowerCase();
const shown = query ? rows.filter(row => row.searchText.includes(query)) : rows;
els.timeline.replaceChildren();
if (!shown.length) {
els.timeline.append(node("div", "empty", query ? "No changes match this filter." : "No catalog updates were found in this date range."));
} else {
const list = node("ol", "commit-list");
shown.forEach(row => list.append(renderCommit(row)));
els.timeline.append(list);
}
els.timeline.setAttribute("aria-busy", "false");
}
function updateMetrics() {
const all = rows.flatMap(row => row.changes);
els.commits.textContent = rows.length.toLocaleString();
els.added.textContent = all.filter(change => change.type === "added").length.toLocaleString();
els.changed.textContent = all.filter(change => change.type === "admin" || change.type === "ransom").length.toLocaleString();
els.latest.textContent = rows.length ? new Date(rows[0].time).toLocaleDateString(undefined, { month: "short", day: "numeric" }) : "No activity";
}
async function load() {
const loadId = ++activeLoad;
let range;
try { range = readRange(); }
catch (error) { els.status.textContent = error.message; els.status.dataset.kind = "error"; return; }
els.apply.disabled = true;
els.search.disabled = true;
els.search.value = "";
els.timeline.setAttribute("aria-busy", "true");
els.timeline.replaceChildren(node("div", "loading", "Loading commit history…"));
els.status.textContent = "Loading commit history…";
els.status.dataset.kind = "";
try {
const historyCutoff = new Date(range.from.getTime() - DAY);
const [jsonHistory, csvHistory] = await Promise.all([
historyFor(FILES.json, historyCutoff), historyFor(FILES.csv, historyCutoff)
]);
if (loadId !== activeLoad) return;
const commits = mergeHistories(jsonHistory, csvHistory).filter(item => {
const time = new Date(item.time);
return time >= range.from && time <= range.to;
});
els.status.textContent = commits.length ? `Comparing 0 of ${commits.length} catalog snapshots…` : "No updates in this date range.";
const compared = await mapLimited(commits, 5, async commit => {
const format = commit.formats.has("json") ? "json" : "csv";
const history = format === "json" ? jsonHistory : csvHistory;
const beforeSha = previousSha(history, commit.sha);
if (!beforeSha) return { ...commit, changes: [] };
const [currentText, previousText] = await Promise.all([
fetchText(`${RAW}/${commit.sha}/${FILES[format]}`),
fetchText(`${RAW}/${beforeSha}/${FILES[format]}`)
]);
const parser = format === "json" ? parseJSON : parseCSV;
return { ...commit, changes: diff(parser(currentText), parser(previousText)) };
}, (done, total) => {
if (loadId === activeLoad) els.status.textContent = `Comparing ${done} of ${total} catalog snapshots…`;
});
if (loadId !== activeLoad) return;
rows = compared.map(row => ({ ...row, searchText: row.changes.map(change => `${change.id} ${change.type} ${change.copy}`).join(" ").toLowerCase() }));
render();
updateMetrics();
els.search.disabled = false;
els.status.textContent = `${rows.length} ${rows.length === 1 ? "commit" : "commits"} from ${range.from.toLocaleDateString()} to ${range.to.toLocaleDateString()}`;
els.refreshed.textContent = `Refreshed ${new Date().toLocaleTimeString(undefined, { hour: "numeric", minute: "2-digit" })}`;
} catch (error) {
if (loadId !== activeLoad) return;
els.timeline.replaceChildren(node("div", "empty", "The timeline could not be loaded. Please try again."));
els.timeline.setAttribute("aria-busy", "false");
els.status.textContent = error.message;
els.status.dataset.kind = "error";
} finally {
if (loadId === activeLoad) els.apply.disabled = false;
}
}
document.querySelectorAll(".preset").forEach(button => button.addEventListener("click", () => {
const range = rangeFor(Number(button.dataset.days));
els.from.value = localISO(range.from); els.to.value = localISO(range.to);
document.querySelectorAll(".preset").forEach(item => item.setAttribute("aria-pressed", String(item === button)));
load();
}));
[els.from, els.to].forEach(input => input.addEventListener("change", () => {
document.querySelectorAll(".preset").forEach(item => item.setAttribute("aria-pressed", "false"));
}));
els.apply.addEventListener("click", load);
els.search.addEventListener("input", event => render(event.target.value));
const themeToggle = $("themeToggle");
const savedTheme = (() => { try { return localStorage.getItem("kev-theme"); } catch { return null; } })();
const preferredTheme = savedTheme || (matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light");
function setTheme(theme) {
document.documentElement.dataset.theme = theme;
themeToggle.textContent = theme === "dark" ? "☀" : "☾";
themeToggle.setAttribute("aria-label", `Use ${theme === "dark" ? "light" : "dark"} theme`);
}
setTheme(preferredTheme);
themeToggle.addEventListener("click", () => {
const theme = document.documentElement.dataset.theme === "dark" ? "light" : "dark";
try { localStorage.setItem("kev-theme", theme); } catch {}
setTheme(theme);
});
const initial = rangeFor(14);
els.from.value = localISO(initial.from); els.to.value = localISO(initial.to);
load();
</script>
</body>
</html>