Repository navigation
Expand file tree
/
Copy pathcve-explorer.html
More file actions
2186 lines (2071 loc) · 119 KB
/
Copy pathcve-explorer.html
File metadata and controls
2186 lines (2071 loc) · 119 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
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>CVE Explorer</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600;700&display=swap">
<style>
/* ============ tokens ============ */
:root {
--bg-deep: oklch(0.13 0.02 280);
--bg-elev-1: oklch(0.95 0.005 280 / 0.04);
--bg-elev-2: oklch(0.95 0.005 280 / 0.06);
--bg-elev-3: oklch(0.95 0.005 280 / 0.08);
--border-1: oklch(0.95 0.005 280 / 0.06);
--border-2: oklch(0.95 0.005 280 / 0.10);
--text-primary: oklch(0.95 0.005 280);
--text-secondary: oklch(0.75 0.02 280);
--text-tertiary: oklch(0.65 0.02 280);
--text-quiet: oklch(0.55 0.02 280);
--accent: oklch(0.7 0.18 300);
--accent-soft: oklch(0.7 0.18 300 / 0.15);
--accent-glow: oklch(0.7 0.18 300 / 0.4);
--red: oklch(0.65 0.2 25);
--orange: oklch(0.70 0.17 55);
--amber: oklch(0.80 0.15 80);
--green: oklch(0.75 0.18 145);
--blue: oklch(0.70 0.15 240);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
background: var(--bg-deep);
color: var(--text-primary);
font-family: Inter, system-ui, sans-serif;
font-size: 14px;
overflow: hidden;
}
::selection { background: oklch(0.7 0.18 300 / 0.35); color: oklch(0.95 0.005 280); }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: oklch(0.95 0.005 280 / 0.12); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }
.mono { font-family: "JetBrains Mono", monospace; }
/* ============ shell ============ */
#shell { display: flex; flex-direction: column; height: 100vh; position: relative; z-index: 1; }
#topbar {
height: 62px; flex: 0 0 62px; display: flex; align-items: center; gap: 14px; padding: 0 20px;
background: var(--bg-elev-1); backdrop-filter: blur(20px);
border-bottom: 1px solid var(--border-1);
}
#topbar .brand { font-weight: 700; font-size: 15px; letter-spacing: 0.4px; display: flex; align-items: center; gap: 10px; }
#topbar .brand .glyph { color: var(--accent); font-size: 18px; }
.pill {
font-family: "JetBrains Mono", monospace; font-size: 10.5px; letter-spacing: 1px;
padding: 4px 10px; border-radius: 20px; border: 1px solid var(--border-2);
background: var(--bg-elev-1); color: var(--text-tertiary); white-space: nowrap;
}
.pill.ok { color: var(--green); border-color: oklch(0.75 0.18 145 / 0.35); }
.pill.warn { color: var(--amber); border-color: oklch(0.8 0.15 80 / 0.35); }
.pill.accent { color: var(--accent); border-color: oklch(0.7 0.18 300 / 0.35); }
#topbar .spacer { flex: 1; }
#mid { display: flex; flex: 1 1 auto; min-height: 0; }
#rail {
width: 248px; flex: 0 0 auto; overflow-y: auto; padding: 16px 14px 30px;
background: var(--bg-elev-1); backdrop-filter: blur(20px);
border-right: 1px solid var(--border-1);
}
#splitter { width: 5px; flex: 0 0 5px; cursor: col-resize; background: transparent; }
#splitter:hover, #splitter.drag { background: var(--accent-soft); }
#main { flex: 1 1 auto; min-width: 0; overflow-y: auto; padding: 26px 30px 60px; scroll-behavior: smooth; }
#logwrap {
flex: 0 0 218px; display: flex; flex-direction: column; min-height: 0;
background: var(--bg-elev-1); backdrop-filter: blur(20px);
border-top: 1px solid var(--border-1);
}
#loghead { display: flex; align-items: center; gap: 12px; padding: 8px 16px; border-bottom: 1px solid var(--border-1); }
#loghead .lbl { font-family: "JetBrains Mono", monospace; font-size: 10px; letter-spacing: 2px; color: var(--text-quiet); }
#logbody { flex: 1; overflow-y: auto; padding: 8px 16px 12px; font-family: "JetBrains Mono", monospace; font-size: 11.5px; line-height: 1.65; }
.log-line { white-space: pre-wrap; word-break: break-word; }
.log-ts { color: var(--text-quiet); margin-right: 8px; }
.lv-info { color: var(--blue); } .lv-ok { color: var(--green); } .lv-warn { color: var(--amber); }
.lv-err { color: var(--red); } .lv-debug { color: var(--text-quiet); }
/* ============ rail ============ */
.rail-sec { margin-bottom: 20px; }
.rail-lbl { font-family: "JetBrains Mono", monospace; font-size: 9.5px; letter-spacing: 2px; color: var(--text-quiet); margin: 0 8px 8px; }
.nav-item {
display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 9px;
color: var(--text-secondary); cursor: pointer; transition: background 150ms ease; font-size: 13px;
border: 1px solid transparent;
}
.nav-item:hover { background: var(--bg-elev-2); }
.nav-item.active { background: var(--accent-soft); color: var(--text-primary); }
.nav-item .ico { width: 16px; text-align: center; color: var(--text-tertiary); }
.nav-item.active .ico { color: var(--accent); }
.cfg-row { margin: 0 4px 10px; }
.cfg-row label { display: block; font-family: "JetBrains Mono", monospace; font-size: 9.5px; letter-spacing: 1.4px; color: var(--text-quiet); margin-bottom: 4px; }
.cfg-row input[type=text], .cfg-row input[type=password], .cfg-row input[type=number], .cfg-row select {
width: 100%; padding: 7px 9px; border-radius: 8px; border: 1px solid var(--border-2);
background: var(--bg-elev-2); color: var(--text-primary);
font-family: "JetBrains Mono", monospace; font-size: 11.5px; outline: none;
transition: border-color 150ms ease;
}
.cfg-row input:focus, .cfg-row select:focus { border-color: var(--accent); }
.cfg-row select option { background: oklch(0.18 0.02 280); color: var(--text-primary); }
.cfg-hint { font-size: 10px; color: var(--text-quiet); margin-top: 3px; line-height: 1.4; }
.seg { display: flex; border: 1px solid var(--border-2); border-radius: 8px; overflow: hidden; }
.seg button {
flex: 1; padding: 7px 0; background: transparent; border: none; color: var(--text-tertiary);
font-family: "JetBrains Mono", monospace; font-size: 11px; cursor: pointer; transition: background 150ms ease;
}
.seg button.on { background: var(--accent-soft); color: var(--text-primary); }
.toggle-row { display: flex; align-items: center; justify-content: space-between; padding: 6px 8px; }
.toggle-row span { font-size: 12.5px; color: var(--text-secondary); }
.tgl { position: relative; width: 34px; height: 19px; border-radius: 10px; background: var(--bg-elev-3); border: 1px solid var(--border-2); cursor: pointer; transition: background 150ms ease; flex: 0 0 auto; }
.tgl::after { content: ""; position: absolute; top: 2px; left: 2px; width: 13px; height: 13px; border-radius: 50%; background: var(--text-tertiary); transition: all 150ms ease; }
.tgl.on { background: var(--accent-soft); border-color: var(--accent); }
.tgl.on::after { left: 17px; background: var(--accent); }
/* ============ cards ============ */
.card {
background: var(--bg-elev-1); border: 1px solid var(--border-2); border-radius: 12px;
backdrop-filter: blur(20px); padding: 20px 22px; margin-bottom: 22px;
}
.card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head .ttl { font-family: "JetBrains Mono", monospace; font-size: 10.5px; letter-spacing: 2.2px; color: var(--text-tertiary); }
.card-head .ico { color: var(--accent); font-size: 15px; }
.card-head .spacer { flex: 1; }
.hint { font-size: 12px; color: var(--text-tertiary); line-height: 1.55; }
button.btn {
padding: 8px 16px; border-radius: 9px; border: 1px solid var(--border-2);
background: var(--bg-elev-2); color: var(--text-primary); font-family: Inter, sans-serif;
font-size: 12.5px; font-weight: 500; cursor: pointer; transition: all 150ms ease;
}
button.btn:hover { background: var(--bg-elev-3); }
button.btn:disabled { opacity: 0.4; cursor: default; }
button.btn.primary { background: var(--accent); border-color: transparent; color: oklch(0.13 0.02 280); font-weight: 600; box-shadow: 0 6px 20px var(--accent-glow); }
button.btn.primary:hover { filter: brightness(1.08); }
button.btn.danger { color: var(--red); border-color: oklch(0.65 0.2 25 / 0.4); }
button.btn.sm { padding: 5px 11px; font-size: 11.5px; }
button.btn.ghost { background: transparent; }
textarea {
width: 100%; min-height: 140px; resize: vertical; padding: 11px 13px;
border-radius: 10px; border: 1px solid var(--border-2); background: var(--bg-elev-2);
color: var(--text-primary); font-family: "JetBrains Mono", monospace; font-size: 12px;
line-height: 1.6; outline: none; transition: border-color 150ms ease;
}
textarea:focus { border-color: var(--accent); }
textarea::-webkit-resizer { background: linear-gradient(135deg, transparent 50%, var(--accent-soft) 50%); }
.progress-track { height: 2px; background: var(--border-1); overflow: hidden; border-radius: 1px; margin-top: 12px; }
.progress-fill { height: 100%; background: var(--accent); width: 0%; transition: width 200ms ease; }
.progress-fill.done { background: var(--green); }
.prog-meta { display: flex; gap: 14px; margin-top: 7px; font-family: "JetBrains Mono", monospace; font-size: 10.5px; color: var(--text-quiet); }
/* ============ database card ============ */
.db-stats { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.stat-tile {
flex: 1 1 130px; min-width: 130px; padding: 12px 14px; border-radius: 10px;
background: var(--bg-elev-2); border: 1px solid var(--border-1);
}
.stat-tile .v { font-family: "JetBrains Mono", monospace; font-size: 21px; font-weight: 600; }
.stat-tile .k { font-family: "JetBrains Mono", monospace; font-size: 9.5px; letter-spacing: 1.6px; color: var(--text-quiet); margin-top: 3px; }
.db-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
/* ============ filters ============ */
.filter-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px 14px; }
.f-field label { display: block; font-family: "JetBrains Mono", monospace; font-size: 9.5px; letter-spacing: 1.4px; color: var(--text-quiet); margin-bottom: 5px; }
.f-field input, .f-field select {
width: 100%; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border-2);
background: var(--bg-elev-2); color: var(--text-primary); font-family: "JetBrains Mono", monospace;
font-size: 12px; outline: none; transition: border-color 150ms ease;
}
.f-field input:focus, .f-field select:focus { border-color: var(--accent); }
.f-field select option { background: oklch(0.18 0.02 280); }
.sev-pills { display: flex; gap: 6px; flex-wrap: wrap; }
.sev-pill {
font-family: "JetBrains Mono", monospace; font-size: 10px; letter-spacing: 0.8px; padding: 5px 10px;
border-radius: 14px; border: 1px solid var(--border-2); cursor: pointer; color: var(--text-quiet);
transition: all 130ms ease; user-select: none;
}
.sev-pill.on { color: var(--text-primary); }
.sev-pill.on[data-sev=CRITICAL] { background: oklch(0.65 0.2 25 / 0.22); border-color: var(--red); }
.sev-pill.on[data-sev=HIGH] { background: oklch(0.7 0.17 55 / 0.22); border-color: var(--orange); }
.sev-pill.on[data-sev=MEDIUM] { background: oklch(0.8 0.15 80 / 0.2); border-color: var(--amber); }
.sev-pill.on[data-sev=LOW] { background: oklch(0.7 0.15 240 / 0.22); border-color: var(--blue); }
.sev-pill.on[data-sev=NONE] { background: var(--bg-elev-3); border-color: var(--text-quiet); }
.chip-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.chip {
font-family: "JetBrains Mono", monospace; font-size: 10.5px; padding: 4px 10px; border-radius: 14px;
background: var(--accent-soft); border: 1px solid oklch(0.7 0.18 300 / 0.3); color: var(--text-secondary);
}
.warn-chip { background: oklch(0.8 0.15 80 / 0.12); border-color: oklch(0.8 0.15 80 / 0.4); color: var(--amber); }
/* ============ dashboard ============ */
.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 980px) { .dash-grid { grid-template-columns: 1fr; } }
.chart-box { background: var(--bg-elev-2); border: 1px solid var(--border-1); border-radius: 10px; padding: 14px 16px; min-width: 0; }
.chart-box .ch-ttl { font-family: "JetBrains Mono", monospace; font-size: 9.5px; letter-spacing: 1.8px; color: var(--text-quiet); margin-bottom: 10px; }
.chart-flex { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.legend { display: flex; flex-direction: column; gap: 6px; }
.leg-row { display: flex; align-items: center; gap: 8px; font-family: "JetBrains Mono", monospace; font-size: 11px; color: var(--text-secondary); }
.leg-dot { width: 9px; height: 9px; border-radius: 3px; flex: 0 0 auto; }
.hbar-row { display: grid; grid-template-columns: minmax(90px, 160px) 1fr 42px; gap: 10px; align-items: center; margin-bottom: 6px; }
.hbar-label { font-family: "JetBrains Mono", monospace; font-size: 11px; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-track { height: 12px; border-radius: 4px; background: var(--bg-elev-1); overflow: hidden; }
.hbar-fill { height: 100%; border-radius: 4px; transition: width 300ms ease; }
.hbar-value { font-family: "JetBrains Mono", monospace; font-size: 11px; color: var(--text-tertiary); text-align: right; }
table.cmp { width: 100%; border-collapse: collapse; font-family: "JetBrains Mono", monospace; font-size: 11.5px; }
table.cmp th { font-size: 9.5px; letter-spacing: 1.3px; color: var(--text-quiet); text-align: right; padding: 6px 10px; border-bottom: 1px solid var(--border-2); }
table.cmp th:first-child, table.cmp td:first-child { text-align: left; }
table.cmp td { padding: 6px 10px; text-align: right; border-bottom: 1px solid var(--border-1); color: var(--text-secondary); }
table.cmp td.hot { color: var(--text-primary); font-weight: 600; }
table.cmp td.prod { text-align: left; max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* ============ results table ============ */
.tbl-toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
table.results { width: 100%; border-collapse: collapse; font-size: 12.5px; table-layout: fixed; }
table.results th {
font-family: "JetBrains Mono", monospace; font-size: 9.5px; letter-spacing: 1.5px; color: var(--text-quiet);
text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border-2); cursor: pointer; user-select: none;
}
table.results th:hover { color: var(--text-secondary); }
table.results td { padding: 8px 10px; border-bottom: 1px solid var(--border-1); vertical-align: top; overflow: hidden; text-overflow: ellipsis; }
table.results tr.row { cursor: pointer; transition: background 130ms ease; }
table.results tr.row:hover { background: var(--bg-elev-2); }
.sev-badge {
font-family: "JetBrains Mono", monospace; font-size: 10px; padding: 2px 8px; border-radius: 11px; white-space: nowrap;
}
.sev-CRITICAL { background: oklch(0.65 0.2 25 / 0.18); color: oklch(0.78 0.16 25); }
.sev-HIGH { background: oklch(0.7 0.17 55 / 0.18); color: oklch(0.8 0.14 55); }
.sev-MEDIUM { background: oklch(0.8 0.15 80 / 0.15); color: var(--amber); }
.sev-LOW { background: oklch(0.7 0.15 240 / 0.16); color: var(--blue); }
.sev-NONE { background: var(--bg-elev-2); color: var(--text-quiet); }
.kev-badge { font-family: "JetBrains Mono", monospace; font-size: 9.5px; padding: 2px 7px; border-radius: 10px; background: oklch(0.65 0.2 25 / 0.22); color: oklch(0.8 0.15 25); border: 1px solid oklch(0.65 0.2 25 / 0.4); }
.xpl-badge { font-family: "JetBrains Mono", monospace; font-size: 9.5px; padding: 2px 7px; border-radius: 10px; background: oklch(0.8 0.15 80 / 0.15); color: var(--amber); }
tr.detail-row td { background: var(--bg-elev-1); padding: 16px 18px; font-size: 12.5px; line-height: 1.65; }
.detail-grid { display: grid; grid-template-columns: 110px 1fr; gap: 6px 14px; margin-top: 10px; font-family: "JetBrains Mono", monospace; font-size: 11.5px; }
.detail-grid .dk { color: var(--text-quiet); }
.detail-grid .dv { color: var(--text-secondary); word-break: break-word; }
.pager { display: flex; gap: 8px; align-items: center; margin-top: 12px; font-family: "JetBrains Mono", monospace; font-size: 11.5px; color: var(--text-tertiary); }
a.ext { color: var(--accent); text-decoration: none; }
a.ext:hover { text-decoration: underline; }
/* ============ prompts ============ */
.prompt-block { margin-bottom: 18px; }
.prompt-head { display: flex; align-items: center; gap: 10px; margin-bottom: 7px; }
.prompt-head .plbl { font-family: "JetBrains Mono", monospace; font-size: 10px; letter-spacing: 1.8px; color: var(--text-tertiary); }
.prompt-head .spacer { flex: 1; }
.prompt-warn { display: none; margin-top: 6px; }
.prompt-warn.show { display: inline-block; }
/* ============ AI card ============ */
.ai-q-row { display: flex; gap: 10px; align-items: flex-start; }
.ai-q-row textarea { min-height: 76px; flex: 1; }
.ai-btn-col { display: flex; flex-direction: column; gap: 8px; }
.answer-box { margin-top: 16px; padding: 16px 18px; border-radius: 10px; background: var(--bg-elev-2); border: 1px solid var(--border-1); border-left: 3px solid var(--accent); }
.answer-box h1, .answer-box h2, .answer-box h3 { font-size: 14px; margin: 12px 0 6px; }
.answer-box p { margin: 7px 0; line-height: 1.65; font-size: 13px; }
.answer-box ul, .answer-box ol { margin: 7px 0 7px 20px; line-height: 1.65; font-size: 13px; }
.answer-box code { font-family: "JetBrains Mono", monospace; font-size: 11.5px; background: var(--bg-elev-2); border: 1px solid var(--border-1); padding: 1px 5px; border-radius: 5px; }
.cite-pill { font-family: "JetBrains Mono", monospace; font-size: 10.5px; padding: 3px 9px; border-radius: 12px; background: var(--accent-soft); border: 1px solid oklch(0.7 0.18 300 / 0.3); color: var(--text-secondary); cursor: pointer; }
.cite-pill.bad { background: oklch(0.65 0.2 25 / 0.15); border-color: oklch(0.65 0.2 25 / 0.45); color: oklch(0.78 0.16 25); }
.validation-block { margin-top: 14px; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--border-1); background: oklch(0.95 0.005 280 / 0.03); border-left-width: 3px; border-left-style: solid; }
.validation-block.ok { border-left-color: oklch(0.75 0.18 145 / 0.8); }
.validation-block.warn { border-left-color: oklch(0.8 0.15 80 / 0.8); }
.validation-block.danger { border-left-color: oklch(0.65 0.2 25 / 0.8); }
.validation-block.neutral { border-left-color: var(--text-quiet); }
.small-lbl { font-family: "JetBrains Mono", monospace; font-size: 9.5px; letter-spacing: 1.8px; color: var(--text-quiet); }
</style>
</head>
<body>
<!-- atmosphere -->
<div style="position:fixed;width:600px;height:600px;border-radius:50%;background:radial-gradient(circle,oklch(0.4 0.18 300/.5),transparent 70%);top:-200px;left:-100px;filter:blur(60px);pointer-events:none;z-index:0"></div>
<div style="position:fixed;width:700px;height:700px;border-radius:50%;background:radial-gradient(circle,oklch(0.4 0.16 240/.4),transparent 70%);bottom:-300px;right:-200px;filter:blur(80px);pointer-events:none;z-index:0"></div>
<div style="position:fixed;inset:0;opacity:0.03;pointer-events:none;z-index:0;background-image:url('data:image/svg+xml;utf8,<svg xmlns=%22http://www.w3.org/2000/svg%22 width=%22100%22 height=%22100%22><filter id=%22n%22><feTurbulence baseFrequency=%220.9%22/></filter><rect width=%22100%22 height=%22100%22 filter=%22url(%23n)%22/></svg>')"></div>
<div id="shell">
<div id="topbar">
<div class="brand"><span class="glyph">◈</span> CVE EXPLORER</div>
<span class="pill mono" id="version-pill">v1.0.0</span>
<span class="pill" id="db-pill">DB: EMPTY</span>
<div class="spacer"></div>
<span class="pill" id="filter-pill">0 / 0 SHOWN</span>
</div>
<div id="mid">
<div id="rail">
<div class="rail-sec">
<div class="rail-lbl">NAVIGATE</div>
<div class="nav-item active" data-target="card-db"><span class="ico">◐</span> Database</div>
<div class="nav-item" data-target="card-filters"><span class="ico">⌕</span> Mining</div>
<div class="nav-item" data-target="card-dash"><span class="ico">▣</span> Dashboard</div>
<div class="nav-item" data-target="card-results"><span class="ico">◇</span> Results</div>
<div class="nav-item" data-target="card-ai"><span class="ico">◬</span> AI Analysis</div>
<div class="nav-item" data-target="card-prompts"><span class="ico">✎</span> Prompts</div>
</div>
<div class="rail-sec">
<div class="rail-lbl">NVD SOURCE</div>
<div class="cfg-row">
<label>NVD API KEY (OPTIONAL)</label>
<input type="password" id="nvd-key" placeholder="speeds up download 10×">
<div class="cfg-hint">Free at nvd.nist.gov/developers — without it the full download takes ~25 min (rate limit).</div>
</div>
</div>
<div class="rail-sec">
<div class="rail-lbl">AI BACKEND</div>
<div class="cfg-row">
<div class="seg" id="backend-seg">
<button data-be="gemini" class="on">Gemini</button>
<button data-be="openrouter">OpenRouter</button>
</div>
</div>
<div id="be-gemini">
<div class="cfg-row">
<label>GEMINI API KEY</label>
<input type="password" id="gemini-key" placeholder="AIza…">
</div>
<div class="cfg-row">
<label>MODEL</label>
<select id="gemini-model">
<option value="gemini-3.7-flash" selected>gemini-3.7-flash</option>
<option value="gemini-3.6-flash">gemini-3.6-flash</option>
<option value="gemini-3.5-flash">gemini-3.5-flash</option>
<option value="gemini-3.5-flash-lite">gemini-3.5-flash-lite</option>
<option value="gemini-3.1-pro-preview">gemini-3.1-pro-preview (paid)</option>
</select>
<div class="cfg-hint">refreshes from the live model API once a key is set</div>
</div>
<div class="cfg-row">
<label>GEMINI CUSTOM ID</label>
<input type="text" id="gemini-model-custom" placeholder="overrides the list">
</div>
<div class="cfg-row">
<label>THINKING LEVEL</label>
<select id="thinking">
<option value="">model default</option>
<option value="minimal">minimal</option>
<option value="low" selected>low</option>
<option value="medium">medium</option>
<option value="high">high</option>
</select>
</div>
</div>
<div id="be-openrouter" style="display:none">
<div class="cfg-row">
<label>OPENROUTER KEY</label>
<input type="password" id="or-key" placeholder="sk-or-…">
</div>
<div class="cfg-row">
<label>MODEL</label>
<select id="or-model-select"><option value="">— load list —</option></select>
</div>
<div class="cfg-row">
<label>OR CUSTOM SLUG</label>
<input type="text" id="or-model-custom" placeholder="vendor/slug (overrides)">
</div>
</div>
</div>
<div class="rail-sec">
<div class="rail-lbl">RUN SETTINGS</div>
<div class="cfg-row"><label>CONCURRENCY</label><input type="number" id="concurrency" value="4" min="1" max="16"></div>
<div class="cfg-row"><label>CHUNK SIZE (CVES/CALL)</label><input type="number" id="chunk-size" value="60" min="5" max="200"></div>
<div class="cfg-row"><label>MAX CVES TO AI</label><input type="number" id="ai-cap" value="120" min="10" max="500"></div>
<div class="cfg-row"><label>MAX RETRIES</label><input type="number" id="retries" value="2" min="0" max="5"></div>
<div class="toggle-row"><span>Question → brief</span><div class="tgl" id="tgl-brief"></div></div>
<div class="toggle-row"><span>Web grounding</span><div class="tgl" id="tgl-grounding"></div></div>
<div class="toggle-row"><span>Maker-Checker</span><div class="tgl" id="tgl-checker"></div></div>
</div>
</div>
<div id="splitter"></div>
<div id="main">
<!-- ============ DATABASE ============ -->
<div class="card" id="card-db">
<div class="card-head"><span class="ico">◐</span><span class="ttl">DATABASE — NVD MIRROR</span>
<div class="spacer"></div><span class="pill" id="sync-pill">NEVER SYNCED</span>
</div>
<div class="db-stats">
<div class="stat-tile"><div class="v" id="st-total">0</div><div class="k">CVES LOCAL</div></div>
<div class="stat-tile"><div class="v" id="st-kev">0</div><div class="k">IN CISA KEV</div></div>
<div class="stat-tile"><div class="v" id="st-years">—</div><div class="k">YEAR RANGE</div></div>
<div class="stat-tile"><div class="v" id="st-size">0 MB</div><div class="k">EST. STORE SIZE</div></div>
</div>
<div class="db-actions">
<div class="f-field" style="min-width:170px">
<label>DOWNLOAD SCOPE</label>
<select id="dl-scope">
<option value="all">Everything (1999 → today)</option>
<option value="2015">From 2015</option>
<option value="2020">From 2020</option>
<option value="2023">From 2023</option>
<option value="2025" selected>From 2025</option>
<option value="2026">From 2026 (smallest)</option>
</select>
</div>
<button class="btn primary" id="btn-download">⤓ Download CVE database</button>
<button class="btn" id="btn-update" disabled>↻ Incremental update</button>
<button class="btn danger ghost" id="btn-wipe" disabled>Wipe local DB</button>
<button class="btn danger" id="btn-cancel-dl" style="display:none">■ Cancel</button>
</div>
<div class="progress-track" id="dl-track" style="display:none"><div class="progress-fill" id="dl-fill"></div></div>
<div class="prog-meta" id="dl-meta" style="display:none"><span id="dl-phase">—</span><span id="dl-count">—</span><span id="dl-eta">—</span></div>
<p class="hint" style="margin-top:12px">Data: NVD API 2.0 (services.nvd.nist.gov), trimmed per CVE to id, dates, description, CVSS, CWE, affected vendor:product, CISA-KEV and exploit-reference flags, then stored in IndexedDB in your browser. Downloads are resumable — cancel any time and press Download again to continue. Nothing leaves your machine except the NVD/AI API calls you trigger.</p>
</div>
<!-- ============ FILTERS ============ -->
<div class="card" id="card-filters">
<div class="card-head"><span class="ico">⌕</span><span class="ttl">MINING — FILTERS</span>
<div class="spacer"></div>
<button class="btn sm ghost" id="btn-clear-filters">Clear all</button>
</div>
<div class="filter-grid">
<div class="f-field" style="grid-column: span 2">
<label>KEYWORD (DESCRIPTION OR CVE-ID)</label>
<input type="text" id="f-keyword" placeholder="e.g. deserialization, log4j, CVE-2021-44228">
</div>
<div class="f-field"><label>YEAR FROM</label><input type="number" id="f-yfrom" placeholder="1999"></div>
<div class="f-field"><label>YEAR TO</label><input type="number" id="f-yto" placeholder="2026"></div>
<div class="f-field"><label>CVSS MIN</label><input type="number" id="f-smin" step="0.1" min="0" max="10" placeholder="0"></div>
<div class="f-field"><label>CVSS MAX</label><input type="number" id="f-smax" step="0.1" min="0" max="10" placeholder="10"></div>
<div class="f-field"><label>VENDOR CONTAINS (COMMA = OR)</label><input type="text" id="f-vendor" placeholder="e.g. microsoft, amazon, google"></div>
<div class="f-field"><label>PRODUCT CONTAINS (COMMA = OR)</label><input type="text" id="f-product" placeholder="e.g. exchange, tomcat"></div>
<div class="f-field"><label>CWE</label><input type="text" id="f-cwe" placeholder="e.g. 79 or CWE-79"></div>
<div class="f-field">
<label>FLAGS</label>
<div class="sev-pills">
<span class="sev-pill" id="f-kev" data-sev="CRITICAL">KEV</span>
<span class="sev-pill" id="f-xpl" data-sev="MEDIUM">EXPLOIT-REF</span>
</div>
</div>
<div class="f-field" style="grid-column: 1 / -1">
<label>SEVERITY</label>
<div class="sev-pills" id="sev-pills">
<span class="sev-pill on" data-sev="CRITICAL">CRITICAL</span>
<span class="sev-pill on" data-sev="HIGH">HIGH</span>
<span class="sev-pill on" data-sev="MEDIUM">MEDIUM</span>
<span class="sev-pill on" data-sev="LOW">LOW</span>
<span class="sev-pill on" data-sev="NONE">UNRATED</span>
</div>
</div>
</div>
<div class="chip-row" id="ai-filter-chips" style="display:none"></div>
</div>
<!-- ============ DASHBOARD ============ -->
<div class="card" id="card-dash" style="display:none">
<div class="card-head"><span class="ico">▣</span><span class="ttl">DASHBOARD — FILTERED SET</span></div>
<div class="dash-grid">
<div class="chart-box" style="grid-column: 1 / -1"><div class="ch-ttl">CVES PER YEAR — STACKED BY SEVERITY</div><div id="chart-years"></div></div>
<div class="chart-box"><div class="ch-ttl">SEVERITY DISTRIBUTION</div><div class="chart-flex"><div id="chart-sev"></div><div class="legend" id="legend-sev"></div></div></div>
<div class="chart-box"><div class="ch-ttl">ATTACK VECTOR (CVSS AV)</div><div class="chart-flex"><div id="chart-av"></div><div class="legend" id="legend-av"></div></div></div>
<div class="chart-box" style="grid-column: 1 / -1"><div class="ch-ttl">CVSS BASE SCORE HISTOGRAM</div><div id="chart-hist"></div></div>
<div class="chart-box"><div class="ch-ttl">TOP WEAKNESSES (CWE)</div><div id="chart-cwe"></div></div>
<div class="chart-box"><div class="ch-ttl">KEV RESPONSE TIME — PUBLICATION → CISA LISTING</div><div id="chart-kevlag"></div></div>
<div class="chart-box" style="grid-column: 1 / -1"><div class="ch-ttl">TOP AFFECTED VENDORS</div><div id="chart-vendor"></div></div>
<div class="chart-box" style="grid-column: 1 / -1"><div class="ch-ttl">TOP AFFECTED PRODUCTS</div><div id="chart-product"></div></div>
<div class="chart-box" style="grid-column: 1 / -1; display:none" id="box-vendor-cmp">
<div class="ch-ttl">VENDOR COMPARISON — YOUR FILTER TERMS</div>
<div id="chart-vendor-cmp"></div>
<p class="hint" style="margin-top:8px">Raw CVE counts reflect portfolio size and disclosure practice as much as security quality — compare shares (KEV %, critical+high %), not absolute totals. A CVE matching several terms is counted in each column.</p>
</div>
</div>
</div>
<!-- ============ RESULTS ============ -->
<div class="card" id="card-results" style="display:none">
<div class="card-head"><span class="ico">◇</span><span class="ttl">RESULTS</span>
<div class="spacer"></div>
<button class="btn sm" id="btn-export-csv">⤓ CSV</button>
<button class="btn sm" id="btn-export-json">⤓ JSON</button>
</div>
<div style="overflow-x:auto">
<table class="results">
<colgroup><col style="width:150px"><col style="width:96px"><col style="width:112px"><col style="width:100px"><col><col style="width:76px"></colgroup>
<thead><tr>
<th data-sort="id">CVE ID</th><th data-sort="pub">PUBLISHED</th><th data-sort="score">CVSS</th>
<th>CWE</th><th>DESCRIPTION</th><th>FLAGS</th>
</tr></thead>
<tbody id="tbl-body"></tbody>
</table>
</div>
<div class="pager">
<button class="btn sm" id="pg-prev">‹</button>
<span id="pg-info">—</span>
<button class="btn sm" id="pg-next">›</button>
</div>
</div>
<!-- ============ AI ============ -->
<div class="card" id="card-ai">
<div class="card-head"><span class="ico">◬</span><span class="ttl">AI ANALYSIS</span>
<div class="spacer"></div>
<span class="pill" id="ai-ctx-pill">CONTEXT: 0 CVES</span>
</div>
<p class="hint" style="margin-bottom:10px">Two modes. <b>Build filter</b>: your question is translated into the deterministic filters above (nothing is generated — the data does the answering). <b>Analyze selection</b>: the top CVEs of the current filtered set (ranked KEV → CVSS → recency, capped by "max CVEs to AI") are sent to the model together with your question.</p>
<div class="ai-q-row">
<textarea id="ai-question" placeholder="e.g. Which critical, remotely exploitable vulnerabilities in Microsoft Exchange since 2023 are known to be exploited, and what do they have in common?"></textarea>
<div class="ai-btn-col">
<button class="btn" id="btn-ai-filter">⌕ Build filter</button>
<button class="btn primary" id="btn-ai-analyze">▶ Analyze selection</button>
<button class="btn danger" id="btn-ai-cancel" style="display:none">■ Cancel</button>
</div>
</div>
<div class="progress-track" id="ai-track" style="display:none"><div class="progress-fill" id="ai-fill"></div></div>
<div class="prog-meta" id="ai-meta" style="display:none"><span id="ai-phase">—</span><span id="ai-count">—</span></div>
<div id="ai-answer"></div>
</div>
<!-- ============ PROMPTS ============ -->
<div class="card" id="card-prompts">
<div class="card-head"><span class="ico">✎</span><span class="ttl">PROMPTS — EDITABLE</span></div>
<div class="prompt-block">
<div class="prompt-head"><span class="plbl">FILTER-BUILDER PROMPT</span><div class="spacer"></div><button class="btn sm ghost" data-reset="filter">Reset to default</button></div>
<textarea id="prompt-filter" style="min-height:200px"></textarea>
<span class="chip warn-chip prompt-warn" id="warn-filter">placeholder {question} missing — it will be appended at runtime</span>
</div>
<div class="prompt-block">
<div class="prompt-head"><span class="plbl">BRIEF PROMPT (QUESTION → ANALYSIS BRIEF)</span><div class="spacer"></div><button class="btn sm ghost" data-reset="brief">Reset to default</button></div>
<textarea id="prompt-brief" style="min-height:200px"></textarea>
<span class="chip warn-chip prompt-warn" id="warn-brief">placeholder {question} or {filter_context} missing — appended at runtime</span>
</div>
<div class="prompt-block">
<div class="prompt-head"><span class="plbl">ANALYSIS PROMPT (PER CHUNK)</span><div class="spacer"></div><button class="btn sm ghost" data-reset="analysis">Reset to default</button></div>
<textarea id="prompt-analysis" style="min-height:220px"></textarea>
<span class="chip warn-chip prompt-warn" id="warn-analysis">placeholder {question} or {records} missing — appended at runtime</span>
</div>
<div class="prompt-block">
<div class="prompt-head"><span class="plbl">SYNTHESIS PROMPT (MERGE CHUNKS)</span><div class="spacer"></div><button class="btn sm ghost" data-reset="synthesis">Reset to default</button></div>
<textarea id="prompt-synthesis" style="min-height:200px"></textarea>
<span class="chip warn-chip prompt-warn" id="warn-synthesis">placeholder {question} or {findings} missing — appended at runtime</span>
</div>
<div class="prompt-block">
<div class="prompt-head"><span class="plbl">CHECKER PROMPT (AUDIT PASS)</span><div class="spacer"></div><button class="btn sm ghost" data-reset="checker">Reset to default</button></div>
<textarea id="prompt-checker" style="min-height:200px"></textarea>
<span class="chip warn-chip prompt-warn" id="warn-checker">placeholder {answer} or {records} missing — appended at runtime</span>
</div>
</div>
</div>
</div>
<div id="logwrap">
<div id="loghead">
<span class="lbl">CONSOLE</span>
<span class="lbl" id="log-count">0 LINES</span>
<div style="flex:1"></div>
<label style="display:flex;align-items:center;gap:6px;font-size:11px;color:var(--text-tertiary);cursor:pointer">
<input type="checkbox" id="log-scroll" checked> autoscroll
</label>
<button class="btn sm ghost" id="log-clear">clear</button>
</div>
<div id="logbody"></div>
</div>
</div>
<script>
"use strict";
/* ================================================================
CVE Explorer — one-page NVD mirror + data mining + AI analysis
Deterministic core: download, storage, filtering, aggregation,
charts, export. LLM only for: NL→filter translation, semantic
analysis of a selected CVE set, optional checker audit.
================================================================ */
const TOOL_VERSION = "1.5.0";
const NVD_API = "https://services.nvd.nist.gov/rest/json/cves/2.0";
const PAGE_SIZE = 2000;
const DESC_CAP = 800;
const VP_CAP = 24;
const LS = k => "cvex_" + k;
const $ = id => document.getElementById(id);
const esc = s => String(s ?? "").replace(/[&<>"']/g, c => ({"&":"&","<":"<",">":">",'"':""","'":"'"}[c]));
const sleep = ms => new Promise(r => setTimeout(r, ms));
const fmtN = n => n.toLocaleString("en-US");
const stripFences = s => s.replace(/^\s*```(?:json)?/i, "").replace(/```\s*$/i, "").trim();
/* ---------------- logger ---------------- */
const l = (() => {
const body = $("logbody"); let count = 0;
function line(lv, msg) {
const d = new Date();
const ts = d.toTimeString().slice(0, 8) + "." + String(d.getMilliseconds()).padStart(3, "0");
const el = document.createElement("div");
el.className = "log-line";
el.innerHTML = `<span class="log-ts">${ts}</span><span class="lv-${lv}">${esc(msg)}</span>`;
body.appendChild(el);
count++; $("log-count").textContent = count + " LINES";
if (body.children.length > 3000) body.removeChild(body.firstChild);
if ($("log-scroll").checked) body.scrollTop = body.scrollHeight;
}
return {
info: m => line("info", m), ok: m => line("ok", m), warn: m => line("warn", m),
err: m => line("err", m), debug: m => line("debug", m),
clear: () => { body.innerHTML = ""; count = 0; $("log-count").textContent = "0 LINES"; }
};
})();
$("log-clear").addEventListener("click", () => l.clear());
/* ---------------- state ---------------- */
const SEVS = ["CRITICAL", "HIGH", "MEDIUM", "LOW", "NONE"];
const SEV_COLORS = {
CRITICAL: "oklch(0.65 0.2 25)", HIGH: "oklch(0.7 0.17 55)", MEDIUM: "oklch(0.8 0.15 80)",
LOW: "oklch(0.7 0.15 240)", NONE: "oklch(0.45 0.02 280)"
};
const state = {
cves: [], // in-memory trimmed records
filtered: [], // indices into cves
meta: null, // {total, lastSync, scope, nextIndex, complete}
running: false, // download running
cancel: false,
aiRunning: false,
aiCancel: false,
sortKey: "pub", sortDir: -1,
filterContext: null, // {question, explanation} from the last successful Build-filter run
page: 0, pageSize: 50,
expanded: null, // expanded row cve id
aiResult: null, // {question, contextIds:Set, answer, validation, error}
};
/* ================================================================
IndexedDB layer — chunked storage (one record = one API page)
================================================================ */
const idb = (() => {
let db = null;
function open() {
return new Promise((res, rej) => {
if (db) return res(db);
const rq = indexedDB.open("cve-explorer", 1);
rq.onupgradeneeded = e => {
const d = e.target.result;
if (!d.objectStoreNames.contains("chunks")) d.createObjectStore("chunks");
if (!d.objectStoreNames.contains("meta")) d.createObjectStore("meta");
};
rq.onsuccess = e => { db = e.target.result; res(db); };
rq.onerror = e => rej(e.target.error);
});
}
async function tx(store, mode, fn) {
const d = await open();
return new Promise((res, rej) => {
const t = d.transaction(store, mode);
const s = t.objectStore(store);
const out = fn(s);
t.oncomplete = () => res(out && out.result !== undefined ? out.result : undefined);
t.onerror = e => rej(e.target.error);
});
}
return {
putChunk: (i, arr) => tx("chunks", "readwrite", s => s.put(arr, i)),
getChunkKeys: () => tx("chunks", "readonly", s => s.getAllKeys()),
getChunk: i => tx("chunks", "readonly", s => s.get(i)),
getAllChunks: () => tx("chunks", "readonly", s => s.getAll()),
clearChunks: () => tx("chunks", "readwrite", s => s.clear()),
putMeta: m => tx("meta", "readwrite", s => s.put(m, "sync")),
getMeta: () => tx("meta", "readonly", s => s.get("sync")),
clearMeta: () => tx("meta", "readwrite", s => s.clear()),
};
})();
/* ================================================================
NVD fetch + trim — fully deterministic
================================================================ */
function trimCve(v) {
const c = v.cve;
const desc = (c.descriptions || []).find(d => d.lang === "en")?.value || "";
// CVSS priority: v4.0 > v3.1 > v3.0 > v2 ; Primary before Secondary
let score = null, sev = "NONE", ver = "", vec = "";
const m = c.metrics || {};
for (const key of ["cvssMetricV40", "cvssMetricV31", "cvssMetricV30", "cvssMetricV2"]) {
const arr = m[key];
if (!arr || !arr.length) continue;
const pick = arr.find(x => x.type === "Primary") || arr[0];
const cd = pick.cvssData || {};
score = cd.baseScore ?? null;
ver = cd.version || "";
vec = cd.vectorString || "";
sev = (cd.baseSeverity || pick.baseSeverity || "").toUpperCase();
if (!sev && score != null) sev = score >= 9 ? "CRITICAL" : score >= 7 ? "HIGH" : score >= 4 ? "MEDIUM" : "LOW";
if (key === "cvssMetricV2" && score != null && (sev === "" || !["CRITICAL","HIGH","MEDIUM","LOW"].includes(sev)))
sev = score >= 7 ? "HIGH" : score >= 4 ? "MEDIUM" : "LOW";
break;
}
if (!SEVS.includes(sev)) sev = score == null ? "NONE" : (score >= 9 ? "CRITICAL" : score >= 7 ? "HIGH" : score >= 4 ? "MEDIUM" : "LOW");
// CWE list (skip NVD-CWE-* placeholders)
const cwes = [];
for (const w of c.weaknesses || [])
for (const d of w.description || [])
if (d.value && d.value.startsWith("CWE-") && !cwes.includes(d.value)) cwes.push(d.value);
// vendor:product pairs from CPE criteria
const vpSet = new Set();
outer: for (const cfg of c.configurations || [])
for (const node of cfg.nodes || [])
for (const mt of node.cpeMatch || []) {
const p = (mt.criteria || "").split(":");
if (p.length > 4 && p[0] === "cpe") {
vpSet.add(p[3] + ":" + p[4]);
if (vpSet.size >= VP_CAP) break outer;
}
}
let xpl = false, refs = 0;
for (const r of c.references || []) { refs++; if ((r.tags || []).includes("Exploit")) xpl = true; }
return {
id: c.id,
pub: (c.published || "").slice(0, 10),
mod: (c.lastModified || "").slice(0, 10),
desc: desc.length > DESC_CAP ? desc.slice(0, DESC_CAP) + "…" : desc,
score, sev, ver, vec,
cwes, vp: [...vpSet],
status: c.vulnStatus || "",
kev: c.cisaExploitAdd || null,
xpl, refs,
};
}
async function nvdFetch(params, attempt = 0) {
const key = $("nvd-key").value.trim();
const url = NVD_API + "?" + new URLSearchParams(params).toString();
const t0 = performance.now();
let res;
try {
res = await fetch(url, { headers: key ? { apiKey: key } : {} });
} catch (e) {
// transient connection drops are normal on long NVD walks — retry like a 503
if (attempt >= 4) throw new Error("network error: " + e.message + " (if this is a CORS error, serve the file via `python -m http.server` and open http://localhost:8000/cve-explorer.html)");
const wait = 8000 * (attempt + 1);
l.warn(`NVD connection dropped (${e.message}) — retrying in ${wait / 1000}s, attempt ${attempt + 1}/4`);
await sleep(wait);
if (state.cancel) throw new Error("cancelled");
return nvdFetch(params, attempt + 1);
}
if (res.status === 403 || res.status === 429 || res.status === 503) {
if (attempt >= 4) throw new Error(`NVD rate limit persists (HTTP ${res.status}) after ${attempt} retries`);
const wait = 15000 * (attempt + 1);
l.warn(`NVD HTTP ${res.status} (rate limit) — backing off ${wait / 1000}s, retry ${attempt + 1}/4`);
await sleep(wait);
if (state.cancel) throw new Error("cancelled");
return nvdFetch(params, attempt + 1);
}
if (!res.ok) throw new Error(`NVD HTTP ${res.status}: ${(await res.text()).slice(0, 300)}`);
const j = await res.json();
l.debug(`NVD page ← ${j.vulnerabilities?.length ?? 0} CVEs, startIndex ${params.startIndex}, ${Math.round(performance.now() - t0)}ms`);
return j;
}
function paceMs() { return $("nvd-key").value.trim() ? 800 : 6500; } // 5 req/30s keyless, 50/30s with key
/* Generic paged fetch over one parameter set; onPage(trimmedArr, total) per page. */
async function fetchAllPages(baseParams, startIndex, onPage) {
let idx = startIndex, total = null, lastStart = 0;
while (true) {
if (state.cancel) throw new Error("cancelled");
const wait = paceMs() - (performance.now() - lastStart);
if (lastStart && wait > 0) await sleep(wait);
lastStart = performance.now();
const j = await nvdFetch({ ...baseParams, resultsPerPage: PAGE_SIZE, startIndex: idx });
total = j.totalResults;
const trimmed = (j.vulnerabilities || []).map(trimCve);
await onPage(trimmed, total, idx);
idx += PAGE_SIZE;
if (idx >= total) break;
}
return total;
}
/* ---------------- download orchestration ---------------- */
function showDlProgress(on) {
$("dl-track").style.display = on ? "" : "none";
$("dl-meta").style.display = on ? "flex" : "none";
$("btn-cancel-dl").style.display = on ? "" : "none";
$("btn-download").disabled = on;
$("btn-update").disabled = on || !state.meta;
$("btn-wipe").disabled = on || !state.cves.length;
}
function setDlProgress(phase, done, total, extraEta) {
const pct = total ? Math.min(100, done / total * 100) : 0;
$("dl-fill").style.width = pct + "%";
$("dl-fill").classList.toggle("done", done >= total && total > 0);
$("dl-phase").textContent = phase;
$("dl-count").textContent = `${fmtN(done)} / ${fmtN(total)}`;
$("dl-eta").textContent = extraEta || "";
}
async function startDownload() {
if (state.running) return;
state.running = true; state.cancel = false;
showDlProgress(true);
let scope = $("dl-scope").value;
try {
let meta = state.meta;
let freshStart = !meta || meta.complete;
if (meta && !meta.complete) {
// an unfinished download always resumes with its stored scope —
// the selector only applies to a fresh start
if (meta.scope !== scope) {
scope = meta.scope;
$("dl-scope").value = scope;
l.info(`resuming unfinished download with its stored scope "${scope}" — wipe the DB first to change scope`);
}
l.info(`resuming download (${meta.chunkCount} pages already stored)`);
} else if (meta && meta.complete) {
const msg = meta.scope === scope
? "Re-download the complete database from scratch? (For daily freshness use Incremental update instead.)"
: `Replace the complete local DB (scope "${meta.scope}") with a fresh "${scope}" download?`;
if (!confirm(msg)) { showDlProgress(false); state.running = false; return; }
}
if (freshStart) {
meta = { scope, nextIndex: 0, chunkCount: 0, total: null, complete: false, lastSync: null };
await idb.clearChunks(); state.cves = [];
}
if (scope === "all") {
await runPlainWalk(meta);
} else {
await runWindowedWalk(meta, parseInt(scope, 10));
}
meta = state.meta;
meta.complete = true;
meta.lastSync = new Date().toISOString();
await idb.putMeta(meta);
setDlProgress("done", 1, 1, "");
l.ok(`download complete — ${fmtN(state.cves.length)} CVEs stored locally`);
setTimeout(() => showDlProgress(false), 900);
} catch (e) {
if (String(e.message) === "cancelled") {
l.warn("download cancelled — progress is saved, press Download again to resume");
} else {
l.err("download failed: " + e.message);
}
showDlProgress(false);
} finally {
state.running = false;
refreshDbStats();
applyFilters();
}
}
async function runPlainWalk(meta) {
state.meta = meta;
const t0 = performance.now();
await fetchAllPages({}, meta.nextIndex, async (trimmed, total, idx) => {
meta.total = total;
const chunkKey = Math.floor(idx / PAGE_SIZE);
await idb.putChunk(chunkKey, trimmed);
state.cves.push(...trimmed);
meta.nextIndex = idx + PAGE_SIZE;
meta.chunkCount = Math.max(meta.chunkCount, chunkKey + 1);
await idb.putMeta(meta);
const done = Math.min(meta.nextIndex, total);
const rate = done - (meta.resumeBase ?? 0) > 0 ? (performance.now() - t0) / (done - (meta.resumeBase ?? (meta.resumeBase = done - trimmed.length))) : 0;
const etaS = rate ? Math.round((total - done) * rate / 1000) : 0;
setDlProgress("downloading", done, total, etaS ? `ETA ~${Math.floor(etaS / 60)}m ${etaS % 60}s` : "");
refreshDbStats();
});
}
async function runWindowedWalk(meta, fromYear) {
state.meta = meta;
// 120-day publication windows from Jan 1 of fromYear to now
const windows = [];
let cur = new Date(Date.UTC(fromYear, 0, 1));
const now = new Date();
while (cur < now) {
const end = new Date(Math.min(cur.getTime() + 119 * 864e5, now.getTime()));
windows.push([cur.toISOString(), end.toISOString()]);
cur = new Date(end.getTime() + 1000);
}
const startWin = meta.window ?? 0;
l.info(`scoped download: ${windows.length} publication windows of ≤120 days (starting at window ${startWin + 1})`);
let chunkKey = meta.chunkCount ?? 0;
for (let w = startWin; w < windows.length; w++) {
if (state.cancel) throw new Error("cancelled");
const [ws, we] = windows[w];
await fetchAllPages({ pubStartDate: ws, pubEndDate: we }, meta.winIndex ?? 0, async (trimmed, total, idx) => {
await idb.putChunk(chunkKey++, trimmed);
state.cves.push(...trimmed);
meta.chunkCount = chunkKey;
meta.window = w; meta.winIndex = idx + PAGE_SIZE;
await idb.putMeta(meta);
setDlProgress(`window ${w + 1}/${windows.length} (${ws.slice(0, 10)})`, w + Math.min(1, (idx + PAGE_SIZE) / Math.max(total, 1)), windows.length, `${fmtN(state.cves.length)} CVEs so far`);
refreshDbStats();
});
meta.window = w + 1; meta.winIndex = 0;
await idb.putMeta(meta);
}
meta.total = state.cves.length;
}
/* ---------------- incremental update ---------------- */
async function startUpdate() {
if (state.running || !state.meta?.lastSync) return;
state.running = true; state.cancel = false;
showDlProgress(true);
try {
const since = new Date(state.meta.lastSync);
const now = new Date();
const windows = [];
let cur = new Date(since.getTime() - 3600e3); // 1h overlap safety
while (cur < now) {
const end = new Date(Math.min(cur.getTime() + 119 * 864e5, now.getTime()));
windows.push([cur.toISOString(), end.toISOString()]);
cur = new Date(end.getTime() + 1000);
}
l.info(`incremental update since ${state.meta.lastSync.slice(0, 16)} — ${windows.length} lastModified window(s)`);
const byId = new Map(state.cves.map((c, i) => [c.id, i]));
let updated = 0, added = 0;
for (let w = 0; w < windows.length; w++) {
const [ws, we] = windows[w];
await fetchAllPages({ lastModStartDate: ws, lastModEndDate: we }, 0, async (trimmed, total) => {
for (const t of trimmed) {
const at = byId.get(t.id);
if (at !== undefined) { state.cves[at] = t; updated++; }
else if (state.meta.scope === "all" || parseInt(t.pub.slice(0, 4), 10) >= parseInt(state.meta.scope, 10)) {
byId.set(t.id, state.cves.length); state.cves.push(t); added++;
}
}
setDlProgress(`update window ${w + 1}/${windows.length}`, w + 1, windows.length, `${updated} updated · ${added} new`);
});
}
// rewrite all chunks (simplest consistent persistence)
l.info("persisting merged database…");
await idb.clearChunks();
let ck = 0;
for (let i = 0; i < state.cves.length; i += PAGE_SIZE)
await idb.putChunk(ck++, state.cves.slice(i, i + PAGE_SIZE));
state.meta.chunkCount = ck;
state.meta.total = state.cves.length;
state.meta.lastSync = now.toISOString();
await idb.putMeta(state.meta);
l.ok(`update complete — ${updated} modified, ${added} new, ${fmtN(state.cves.length)} total`);
setDlProgress("done", 1, 1, "");
setTimeout(() => showDlProgress(false), 900);
} catch (e) {
if (String(e.message) === "cancelled") l.warn("update cancelled — local DB unchanged on disk until merge finished");
else l.err("update failed: " + e.message);
showDlProgress(false);
} finally {
state.running = false;
refreshDbStats();
applyFilters();
}
}
async function wipeDb() {
if (state.running) return;
if (!confirm("Delete the local CVE database (IndexedDB)? The NVD is not affected; you can re-download any time.")) return;
await idb.clearChunks(); await idb.clearMeta();
state.cves = []; state.meta = null;
l.warn("local database wiped");
refreshDbStats(); applyFilters();
}
/* ---------------- load from IDB at startup ---------------- */
async function loadLocal() {
const meta = await idb.getMeta();
if (!meta) { l.info("no local database yet — choose a scope and press Download"); refreshDbStats(); return; }
state.meta = meta;
if (meta.scope) $("dl-scope").value = meta.scope; // reflect the stored scope in the selector
const t0 = performance.now();
const chunks = await idb.getAllChunks();
state.cves = [];
for (const ch of chunks) if (Array.isArray(ch)) state.cves.push(...ch);
l.ok(`loaded ${fmtN(state.cves.length)} CVEs from IndexedDB in ${Math.round(performance.now() - t0)}ms` +
(meta.complete ? "" : " — download incomplete, press Download to resume"));
refreshDbStats();
}
function refreshDbStats() {
const n = state.cves.length;
$("st-total").textContent = fmtN(n);
let kev = 0, ymin = null, ymax = null, bytes = 0, noCpe = 0;
for (const c of state.cves) {
if (c.kev) kev++;
if (!c.vp.length) noCpe++;
const y = +c.pub.slice(0, 4);
if (y) { if (ymin === null || y < ymin) ymin = y; if (ymax === null || y > ymax) ymax = y; }
}
state.noCpeTotal = noCpe;
// rough size estimate: sample every 200th record
for (let i = 0; i < n; i += 200) bytes += JSON.stringify(state.cves[i]).length * Math.min(200, n - i);
$("st-kev").textContent = fmtN(kev);
$("st-years").textContent = ymin ? `${ymin}–${ymax}` : "—";
$("st-size").textContent = (bytes / 1048576).toFixed(0) + " MB";
$("db-pill").textContent = n ? `DB: ${fmtN(n)} CVES` : "DB: EMPTY";
$("db-pill").className = "pill " + (n ? (state.meta?.complete ? "ok" : "warn") : "");
$("sync-pill").textContent = state.meta?.lastSync ? "SYNCED " + state.meta.lastSync.slice(0, 16).replace("T", " ") + "Z" : (state.meta ? "PARTIAL — RESUME AVAILABLE" : "NEVER SYNCED");
$("btn-update").disabled = state.running || !state.meta?.lastSync;
$("btn-wipe").disabled = state.running || !n;
$("btn-download").textContent = state.meta && !state.meta.complete ? "⤓ Resume download" : "⤓ Download CVE database";