-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathscript.js
More file actions
1878 lines (1775 loc) · 82.7 KB
/
script.js
File metadata and controls
1878 lines (1775 loc) · 82.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
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
function loadQueryString() {
const queryString = window.location.search;
if(queryString && queryString.length >= 1) {
var q = decodeURIComponent(queryString.substring(1));
document.getElementById("q").value = q
if (q) {
getCVEs(q);
handleHashChange();
}
}
}
function handleHashChange() {
// 1. Extract the raw fragment, remove the leading '#'
const rawHash = window.location.hash;
const fragment = rawHash.startsWith('#') ? rawHash.substring(1) : rawHash;
if (!fragment) {
return;
}
if (isValidCveFormat(fragment)) {
loadEntry(fragment);
}
}
window.addEventListener('hashchange', handleHashChange);
function isValidCveFormat(id) {
// Regex for 'CVE-YYYY-NNNN+' (case-insensitive for robustness)
// It requires "cve-", followed by 4 digits, followed by '-', and at least 4 more digits.
const cveRegex = /^cve-\d{4}-\d{4,}$/i;
return cveRegex.test(id);
}
function extractUniqueCVEs(input) {
const cvePattern = /CVE-(\d{4})-(\d{4,6})/g;
const uniqueCVEs = new Set();
let match;
var yearNow = new Date().getFullYear()+2;
while ((match = cvePattern.exec(input.toUpperCase())) !== null) {
const year = parseInt(match[1], 10);
if (year > 1997 && year <= yearNow ) {
uniqueCVEs.add(match[0]);
}
}
return Array.from(uniqueCVEs).sort((a, b) => {
const [_, yearA, idA] = a.match(/CVE-(\d{4})-(\d+)/);
const [__, yearB, idB] = b.match(/CVE-(\d{4})-(\d+)/);
return yearA !== yearB ? yearA - yearB : idA - idB;
});
;
}
const CNA_REGEX = /CNA:(\"([^\"]+)\"|([^\s]+))/i;
async function fetchCnaCveList(sName) {
var url = 'https://raw.githubusercontent.com/Vulnogram/cve-index/refs/heads/main/data/latest/' + sName + '.json';
var response = await fetch(url, {
method: 'GET',
credentials: 'omit',
headers: {
'Accept': 'application/json, text/plain, */*'
},
redirect: 'error'
});
if (!response.ok) {
throw Error('Failed to load CNA list ' + sName + ' ' + response.statusText);
}
var data = await response.json();
if (!Array.isArray(data)) {
return [];
}
var seen = new Set();
var normalized = [];
data.forEach(function (id) {
var rawId = ('' + id).trim();
if (!rawId) {
return;
}
var formatted = rawId.toUpperCase();
if (!formatted.startsWith('CVE-')) {
formatted = 'CVE-' + formatted;
}
if (!seen.has(formatted)) {
seen.add(formatted);
normalized.push(formatted);
}
});
return normalized;
}
var cnaSearchID = '';
async function resolveCnaCves(text) {
if (!text) {
return [];
}
var match = text.match(CNA_REGEX);
if (!match) {
return [];
}
try {
cnaSearchID = match[2] || match[1];
return await fetchCnaCveList(normalizeShortName(cnaSearchID));
} catch (err) {
console.warn('Unable to fetch CNA CVE list', err);
return [];
}
}
const SEARCH_PAGE_SIZE = 30;
var searchState = {
query: '',
items: [],
nextCursor: null,
loading: false
};
var manualListState = {
active: false,
allItems: [],
nextIndex: 0
};
function resetManualListState() {
manualListState.active = false;
manualListState.allItems = [];
manualListState.nextIndex = 0;
}
function resetSearchState(query = '') {
searchState.query = query;
searchState.items = [];
searchState.nextCursor = null;
searchState.loading = false;
}
function updateLoadMoreButton() {
var button = document.getElementById('loadMoreBtn');
if (!button) {
return;
}
var manualHasMore = manualListState.active && manualListState.nextIndex < manualListState.allItems.length;
var searchHasMore = Boolean(searchState.query) &&
searchState.items.length > 0 &&
searchState.nextCursor !== null;
var shouldShow = manualHasMore || searchHasMore;
button.classList.toggle('hid', !shouldShow);
button.disabled = searchState.loading;
if (shouldShow) {
button.textContent = searchState.loading ? 'Loading...' : 'Load more';
}
}
function updateStatusTextMessage(cveList, textSearch) {
var statusText = document.getElementById('statusText');
if (!statusText || !Array.isArray(cveList)) {
return;
}
var count = cveList.length;
var hasMore = false;
if (textSearch) {
hasMore = searchState.nextCursor !== null;
} else if (manualListState.active) {
hasMore = manualListState.nextIndex < manualListState.allItems.length;
}
var plus = hasMore ? '+' : '';
var plural = count === 1 ? '' : 's';
statusText.innerText = `Found ${count}${plus} CVE${plural}: ${cveList.join(', ')}`;
}
function clearURL() {
history.replaceState && history.replaceState(
null, '', location.pathname
);
}
var entryView = false;
var multiResultMode = false;
var selectedEntryId = null;
var listPanelWidth = 320;
var listPanelMinWidth = 220;
var listPanelMaxWidth = 1200;
var userResizedList = false;
function getPanelList() {
return document.querySelector('.panel-list');
}
function getLayoutRoot() {
return document.getElementById('masterDetail');
}
function setInlineListWidth(width) {
var panelList = getPanelList();
if (!panelList) {
return;
}
listPanelWidth = width;
panelList.style.flex = '0 0 ' + width + 'px';
panelList.style.flexBasis = width + 'px';
panelList.style.width = width + 'px';
}
function clearInlineListWidth() {
var panelList = getPanelList();
if (!panelList) {
return;
}
panelList.style.removeProperty('flex');
panelList.style.removeProperty('flex-basis');
panelList.style.removeProperty('width');
}
function resetListPanelSizing() {
userResizedList = false;
listPanelWidth = 320;
clearInlineListWidth();
var layout = getLayoutRoot();
if (layout) {
layout.classList.remove('resized');
}
}
function setSplitMode(isSplit) {
var layout = getLayoutRoot();
multiResultMode = isSplit;
if (!layout) {
return;
}
layout.classList.toggle('split', isSplit);
layout.classList.toggle('single', !isSplit);
layout.dataset.state = isSplit ? 'list' : 'detail';
if (!isSplit) {
resetListPanelSizing();
return;
}
layout.classList.remove('resized');
clearInlineListWidth();
}
function setLayoutState(state) {
var layout = getLayoutRoot();
if (!layout) {
return;
}
layout.dataset.state = state;
if (!multiResultMode) {
return;
}
if (state === 'detail' && userResizedList) {
layout.classList.add('resized');
setInlineListWidth(listPanelWidth);
}
if (state === 'list') {
window.scrollTo(0,listPosition);
layout.classList.remove('resized');
if (userResizedList) {
clearInlineListWidth();
}
}
}
function showListPanel() {
if (!multiResultMode) {
return;
}
setLayoutState('list');
}
function showDetailPanel() {
window.scrollTo(0,0);
setLayoutState('detail');
}
function highlightRow(id) {
if (selectedEntryId) {
var previousRow = document.getElementById('i' + selectedEntryId);
if (previousRow) {
previousRow.classList.remove('selected');
}
}
selectedEntryId = id || null;
if (!selectedEntryId) {
return;
}
var currentRow = document.getElementById('i' + selectedEntryId);
if (currentRow) {
currentRow.classList.add('selected');
listPosition = window.scrollY;
}
}
function clampListWidth(width) {
var layout = getLayoutRoot();
var layoutWidth = layout ? layout.getBoundingClientRect().width : window.innerWidth;
var dynamicMax = Math.max(listPanelMinWidth, Math.min(listPanelMaxWidth, layoutWidth - listPanelMinWidth));
if (!Number.isFinite(dynamicMax) || dynamicMax < listPanelMinWidth) {
dynamicMax = listPanelMaxWidth;
}
return Math.max(listPanelMinWidth, Math.min(dynamicMax, width));
}
function setupSplitterResize() {
var splitter = document.querySelector('.splitter');
var panelList = getPanelList();
if (!splitter || !panelList) {
return;
}
var dragging = false;
var startX = 0;
var startWidth = 0;
var layout = getLayoutRoot();
var isDesktop = () => !window.matchMedia('(max-width: 768px)').matches;
function stopDrag() {
if (!dragging) {
return;
}
dragging = false;
document.body.classList.remove('resizing');
panelList.classList.remove('resizing');
window.removeEventListener('pointermove', onPointerMove);
window.removeEventListener('pointerup', stopDrag);
window.removeEventListener('pointercancel', stopDrag);
}
function onPointerMove(evt) {
if (!dragging) {
return;
}
var delta = evt.clientX - startX;
var newWidth = clampListWidth(startWidth + delta);
setInlineListWidth(newWidth);
}
splitter.addEventListener('pointerdown', function (evt) {
if (!multiResultMode || !isDesktop()) {
return;
}
dragging = true;
userResizedList = true;
layout = getLayoutRoot();
startX = evt.clientX;
var currentWidth = panelList.getBoundingClientRect().width;
layout && layout.classList.add('resized');
setInlineListWidth(currentWidth);
startWidth = listPanelWidth;
document.body.classList.add('resizing');
panelList.classList.add('resizing');
window.addEventListener('pointermove', onPointerMove);
window.addEventListener('pointerup', stopDrag);
window.addEventListener('pointercancel', stopDrag);
evt.preventDefault();
});
}
async function getCVEs(text) {
const container = document.getElementById('container');
const backButton = document.getElementById('backButton');
container.classList.add('busy');
backButton.classList.add('hid');
const results = document.getElementById('results');
const list = document.getElementById('idxTble');
const statusText = document.getElementById('statusText');
resetSearchState();
resetManualListState();
updateLoadMoreButton();
//resetSort(list.parentElement);
var textSearch = false;
var cnaSearch = false;
var cves = await resolveCnaCves(text);
if (cves.length === 0) {
cves = extractUniqueCVEs(text);
} else {
cnaSearch = true;
}
if (cves.length === 0) {
if(text.length > 0 && text.length <= 100) {
textSearch = true;
searchState.query = text;
searchState.loading = true;
updateLoadMoreButton();
const initialResults = await searchCve(text, { cursor: 0, pageSize: SEARCH_PAGE_SIZE });
searchState.loading = false;
if(initialResults && initialResults.items && initialResults.items.length > 0) {
searchState.items = initialResults.items.slice();
searchState.nextCursor = initialResults.nextCursor ?? null;
cves = searchState.items.slice();
} else {
resetSearchState();
clearURL();
results.classList.add('visible');
document.getElementById('entry').innerHTML = '';
statusText.innerText = `No matching CVEs found. Please enter CVE IDs CVE-year-nnnn or fewer keywords.`;
}
updateLoadMoreButton();
} else {
clearURL();
results.classList.add('visible');
document.getElementById('entry').innerHTML = '';
statusText.innerText = `Please enter one or more valid CVE IDs CVE-year-nnnn format or fewer keywords.`;
}
}
entryView = !textSearch && (cves.length == 1);
resetListPanelSizing();
var shouldSplit = textSearch ? cves.length >= 1 : cves.length > 1;
setSplitMode(shouldSplit);
if (cves.length >= 1) {
if (!textSearch) {
clearURL();
}
container.classList.add('moved-up');
results.classList.add('visible');
list.innerHTML = '';
highlightRow(null);
if (cves.length > 1 || textSearch)
list.parentElement.classList.remove('hid');
var displayList = cves;
if (!textSearch && cves.length > SEARCH_PAGE_SIZE) {
manualListState.active = true;
manualListState.allItems = cves.slice();
manualListState.nextIndex = SEARCH_PAGE_SIZE;
displayList = manualListState.allItems.slice(0, SEARCH_PAGE_SIZE);
}
var statusValues = textSearch ? searchState.items : displayList;
updateStatusTextMessage(statusValues, textSearch);
document.getElementById('entry').innerHTML = '';
displayList.forEach(cve => {
addContainer(cve);
});
displayList.forEach(cve => {
loadCVE(cve);
});
if(textSearch) {
document.title = text;
history.pushState({text:text}, null, "?"+encodeURIComponent(text));
} else if (cnaSearch) {
//document.title = 'Recent ' + cves[0].cveMetadata.assignerShortName;
history.pushState({cves:cves}, null, "?CNA:" + cnaSearchID);
} else {
document.title = cves.join(' ');
history.pushState({cves:cves}, null, "?"+cves);
}
updateLoadMoreButton();
}
if (cves.length>1) {
backButton.classList.remove('hid');
}
if (textSearch && cves.length >= 1) {
list.parentElement.classList.remove('hid');
} else if (cves.length <= 1) {
list.parentElement.classList.add('hid');
}
if (entryView) {
showDetailPanel();
} else {
showListPanel();
}
setTimeout(function(){container.classList.remove('busy')},1000);
}
var cveCache = {};
var entryCache = {};
function fetchCveJson(url, id) {
return fetch(url, {
method: 'GET',
credentials: 'omit',
headers: {
'Accept': 'application/json, text/plain, */*'
},
redirect: 'error'
})
.then(function (response) {
if (!response.ok) {
throw Error('Failed to load ' + id + ' ' + response.statusText);
}
return response.json();
});
}
function nvdToAdp(nvdJson) {
if (!nvdJson) return null;
var cveMetrics = [];
// NVD 2.0 format: metrics.cvssMetricV40 / cvssMetricV31 / cvssMetricV30 / cvssMetricV2
// Each entry: { source, type, cvssData } — only take NIST-scored entries
var nvdMetrics = nvdJson.metrics || {};
var mapping = [
[nvdMetrics.cvssMetricV40, 'cvssV4_0'],
[nvdMetrics.cvssMetricV31, 'cvssV3_1'],
[nvdMetrics.cvssMetricV30, 'cvssV3_0'],
[nvdMetrics.cvssMetricV2, 'cvssV2_0']
];
mapping.forEach(function (pair) {
(pair[0] || []).filter(function (entry) {
return entry.source === 'nvd@nist.gov';
}).forEach(function (entry) {
if (entry.cvssData) {
// cvssData field names match CVE JSON 5.0 container format directly
var m = {};
m[pair[1]] = entry.cvssData;
cveMetrics.push(m);
}
});
});
// NVD 1.x format: impact.baseMetricV3 / baseMetricV2
var impact = nvdJson.impact || {};
if (impact.baseMetricV3 && impact.baseMetricV3.cvssV3) {
var v3 = impact.baseMetricV3.cvssV3;
var m3 = {};
m3[v3.version === '3.0' ? 'cvssV3_0' : 'cvssV3_1'] = {
version: v3.version,
vectorString: v3.vectorString,
baseScore: v3.baseScore,
baseSeverity: v3.baseSeverity
};
cveMetrics.push(m3);
}
if (impact.baseMetricV2 && impact.baseMetricV2.cvssV2) {
var v2 = impact.baseMetricV2.cvssV2;
cveMetrics.push({
cvssV2_0: {
version: '2.0',
vectorString: v2.vectorString,
baseScore: v2.baseScore,
baseSeverity: impact.baseMetricV2.severity
}
});
}
var hasMetrics = cveMetrics.length > 0;
var hasDescriptions = nvdJson.descriptions && nvdJson.descriptions.length > 0;
if (!hasMetrics && !hasDescriptions) return null;
var adp = {
providerMetadata: {
dateUpdated: nvdJson.lastModified || nvdJson.lastModifiedDate,
shortName: 'NIST'
}
};
if (hasMetrics) adp.metrics = cveMetrics;
if (hasDescriptions) adp.descriptions = nvdJson.descriptions;
return adp;
}
function loadCVE(value) {
var realId = value.match(/(CVE-(\d{4})-(\d{1,12})(\d{3}))/);
if (realId) {
var id = realId[1];
var year = realId[2];
var bucket = realId[3];
var jsonURL = 'https://github.com/CVEProject/cvelistV5/blob/main/cves/' + year + '/' + bucket + 'xxx/' + id + '.json'
var rawUrl = 'https://raw.githubusercontent.com/CVEProject/cvelistV5/main/cves/' + year + '/' + bucket + 'xxx/' + id + '.json';
var cveAwgUrl = 'https://cveawg.mitre.org/api/cve/' + id;
fetchCveJson(rawUrl, id)
.catch(function (primaryError) {
//console.warn('Primary CVE source failed for ' + id, primaryError);
return fetchCveJson(cveAwgUrl, id);
})
.then(function (res) {
if (res.containers) {
var nvdUrl = 'https://raw.githubusercontent.com/olbat/nvdcve/refs/heads/master/nvdcve/' + id + '.json';
var warningsUrl = 'https://raw.githubusercontent.com/Vulnogram/cve-index/refs/heads/main/warnings/cves/' + year + '/' + bucket + 'xxx/' + id + '.json';
Promise.all([
fetch(nvdUrl)
.then(function (r) { return r.ok ? r.json() : null; })
.catch(function () { return null; }),
fetch(warningsUrl)
.then(function (r) { return r.ok ? r.json() : null; })
.catch(function () { return null; })
]).then(function (results) {
var nvdJson = results[0];
var warningsJson = results[1];
var nistAdp = nvdToAdp(nvdJson);
if (nistAdp) {
if (nistAdp.descriptions) {
var cnaDescs = new Set(
((res.containers.cna || {}).descriptions || []).map(function (d) { return d.value; })
);
nistAdp.descriptions = nistAdp.descriptions.filter(function (d) {
return !cnaDescs.has(d.value);
});
if (nistAdp.descriptions.length === 0) delete nistAdp.descriptions;
}
if (nistAdp.metrics || nistAdp.descriptions) {
if (!Array.isArray(res.containers.adp)) {
res.containers.adp = res.containers.adp ? Object.values(res.containers.adp) : [];
}
res.containers.adp.push(nistAdp);
}
}
preProcess(res);
if (warningsJson && warningsJson.warnings && warningsJson.warnings.length > 0) {
res.containers.cna.indexWarnings = warningsJson.warnings;
}
cveCache[id] = res;
delete entryCache[id];
res.jsonURL = jsonURL;
if (entryView) {
loadEntry(id);
} else {
loadItem(res);
}
});
} else {
statusText.textContent = statusText.textContent + " Failed to load " + id;
}
})
.catch(function (error) {
statusText.textContent = statusText.textContent + ' ' + error.message;
})
} else {
//console.log("CVE ID required");
}
return false;
}
async function loadMoreResults() {
var manualHasMore = manualListState.active && manualListState.nextIndex < manualListState.allItems.length;
if (manualHasMore) {
var nextManualItems = manualListState.allItems.slice(manualListState.nextIndex, manualListState.nextIndex + SEARCH_PAGE_SIZE);
manualListState.nextIndex += nextManualItems.length;
nextManualItems.forEach(function (cveId) {
addContainer(cveId);
});
nextManualItems.forEach(function (cveId) {
loadCVE(cveId);
});
updateStatusTextMessage(manualListState.allItems.slice(0, manualListState.nextIndex), false);
updateLoadMoreButton();
return;
}
if (!searchState.query || searchState.nextCursor === null || searchState.loading) {
return;
}
searchState.loading = true;
updateLoadMoreButton();
try {
const nextPage = await searchCve(searchState.query, {
cursor: searchState.items.length,
pageSize: SEARCH_PAGE_SIZE
});
if (nextPage && Array.isArray(nextPage.items) && nextPage.items.length > 0) {
nextPage.items.forEach(cveId => {
addContainer(cveId);
});
}
if (nextPage && Array.isArray(nextPage.items) && nextPage.items.length > 0) {
nextPage.items.forEach(cveId => {
searchState.items.push(cveId);
loadCVE(cveId);
});
}
searchState.nextCursor = nextPage && nextPage.nextCursor !== null ? nextPage.nextCursor : null;
if (searchState.items.length > 0) {
updateStatusTextMessage(searchState.items, true);
}
} catch (err) {
console.error('Failed to load more results', err);
} finally {
searchState.loading = false;
updateLoadMoreButton();
}
}
// adds an element to the array if it does not already exist using a comparer
// function
function addUniq(array, element) {
var index = array.indexOf(element);
if (index === -1) {
array.push(element);
}
};
function versionStatusTable4(affects) {
var collator = new Intl.Collator(undefined, {numeric: true});
nameAndPlatforms = {};
var table= {
affected: {},
unaffected: {},
unknown: {}
};
var showCols = {
platforms: false,
affected: false,
unaffected: false,
unknown: false
};
for (var vendor of affects.vendor.vendor_data) {
var vendor_name = vendor.vendor_name;
for(var product of vendor.product.product_data) {
var product_name = product.product_name;
for(var version of product.version.version_data) {
var vv = version.version_value;
var cat = "affected";
var platforms = "";
var major = version.version_name ? version.version_name : "";
if(!version.version_affected && version.affected) {
version.version_affected = version.affected;
}
if(version.version_affected) {
if(version.version_affected.startsWith('?')) {
cat = "unknown";
} else if (version.version_affected.startsWith('!')) {
cat = "unaffected";
}
switch (version.version_affected) {
case "!":
case "?":
case "=":
vv = version.version_value;
break;
case "<":
case "!<":
case "?<":
vv = "< " + version.version_value;
break;
case ">":
case "!>":
case "?>":
vv = "> " + version.version_value;
break;
case "<=":
case "!<=":
case "?<=":
vv = "<= " + version.version_value;
break;
case ">=":
case "!>=":
case "?>=":
vv = ">= " + version.version_value;
break;
default:
vv = version.version_value;
}
}
if (cat)
showCols[cat] = true;
if (version.platform && version.platform != "") {
showCols.platforms = true;
platforms = version.platform;
}
var pFullName = [(vendor_name? vendor_name + ' ': '') + product_name + (major ? ' ' + major : ''), platforms];
nameAndPlatforms[pFullName] = pFullName;
if(!table[cat][pFullName]) {
table[cat][pFullName] = [];
}
if (vv) {
table[cat][pFullName].push(vv);
}
}
}
}
return({cols:nameAndPlatforms, vals:table, show: showCols});
}
/* fullname = vendor . product . platforms . module .others
/* table --> [ fullname ][version][affected|unaffected|unknown] = [ list of ranges ] */
function versionStatusTable5(affected) {
var t = {};
nameAndPlatforms = {};
var showCols = {
platforms: false,
modules: false,
affected: false,
unaffected: false,
unknown: false
};
for(var p of affected) {
var pname = p.product ? p.product : p.packageName ? p.packageName : '';
if (p.platforms)
showCols.platforms = true;
if (p.modules)
showCols.modules = true;
if (p.status)
showCols[p.status] = true;
var platforms =
(p.platforms ? p.platforms.join(', '): '');
var others = {};
if(p.collectionURL) {
others.collectionURL = p.collectionURL;
}
if(p.repo) {
others.repo = p.repo;
}
if(p.programFiles) {
others.programFiles = p.programFiles;
}
if(p.programRoutines) {
others.programRoutines = p.programRoutines;
}
//pname = pname + platforms;
var modules = p.modules ? p.modules.join(', ') : '';
if(p.versions) {
for(v of p.versions) {
var rows = {
affected: [],
unaffected: [],
unknown: []
};
var major = undefined;//major ? major[1] : '';
var pFullName = [(p.vendor ? p.vendor + ' ' : '') + pname + (major ? ' ' + major : ''), platforms, modules, others];
nameAndPlatforms[pFullName] = pFullName;
if (v.version) {
showCols[v.status] = true;
if(!v.changes) {
var rangeStart = '';
if (v.version != 'unspecified' && v.version != 0)
rangeStart = 'from ' + v.version;
if(v.lessThan) {
var rangeEnd = ' before ' + v.lessThan;
if(v.lessThan == 'unspecified' || v.lessThan == '*')
rangeEnd = "";
rows[v.status].push(rangeStart + rangeEnd);
} else if(v.lessThanOrEqual) {
var rangeEnd = ' through ' + v.lessThanOrEqual;
if (v.lessThanOrEqual == 'unspecified' || v.lessThanOrEqual == '*')
rangeEnd = "";
rows[v.status].push(rangeStart + rangeEnd);
} else {
rows[v.status].push(v.version);
}
} else {
var prevStatus = v.status;
var prevVersion = v.version;
showCols[prevStatus] = true;
var range = '';
if (prevVersion != 'unspecified' && prevVersion != 0)
range = 'from ' + prevVersion;
if(v.lessThan) {
var rangeEnd = ' before ' + v.lessThan;
if(v.lessThan == 'unspecified' || v.lessThan == '*')
rangeEnd = "";
range = range + (v.lessThan != prevVersion ? rangeEnd : '');
} else if(v.lessThanOrEqual) {
var rangeEnd = ' through ' + v.lessThanOrEqual;
if (v.lessThanOrEqual == 'unspecified' || v.lessThanOrEqual == '*')
rangeEnd = "";
range = range + (v.lessThanOrEqual != prevVersion ? rangeEnd : '');
} else {
range = prevVersion;
}
var changes = [];
for(c of v.changes) {
changes.push(c.status + ' from ' + c.at);
}
if(changes.length > 0) {
range = range + ' (' + changes.join(', ') + ')';
}
rows[v.status].push(range);
}
}
if(!t[pFullName]) t[pFullName] = [];
//if(!t[pFullName][v.version]) t[pFullName][v.version] = [];
t[pFullName].push(rows);
}
}
var pFullName = [(p.vendor ? p.vendor + ' ' : '') + pname + (major ? ' ' + major : ''), platforms, modules, others];
nameAndPlatforms[pFullName] = pFullName;
var rows = {};
if (p.defaultStatus) {
rows[p.defaultStatus] = ["everything else"];
showCols[p.defaultStatus] = true;
if(!t[pFullName]) {
t[pFullName] = [rows];
} else {
t[pFullName].push(rows);
}
}
}
return({groups:nameAndPlatforms, vals:t, show: showCols});
}
cvssDesc = {
"attackVector": {
"title": "Attack Vector",
"infoText": "This metric reflects the context by which vulnerability exploitation is possible. This metric value (and consequently the resulting severity) will be larger the more remote (logically, and physically) an attacker can be in order to exploit the vulnerable system. The assumption is that the number of potential attackers for a vulnerability that could be exploited from across a network is larger than the number of potential attackers that could exploit a vulnerability requiring physical access to a device, and therefore warrants a greater severity.",
"PHYSICAL": {
"title": "Physical",
"infoText": "The attack requires the attacker to physically touch or manipulate the vulnerable system. Physical interaction may be brief (e.g., evil maid attack) or persistent.",
"icon": "cvss-physical"
},
"LOCAL": {
"title": "Local",
"infoText": "The vulnerable system is not bound to the network stack and the attacker\u2019s path is via read/write/execute capabilities. Either the attacker exploits the vulnerability by accessing the target system locally (e.g., keyboard, console), or through terminal emulation (e.g., SSH); or the attacker relies on User Interaction by another person to perform actions required to exploit the vulnerability (e.g., using social engineering techniques to trick a legitimate user into opening a malicious document).",
"icon": "cvss-user"
},
"ADJACENT": {
"title": "Adjacent",
"infoText": "The vulnerable system is bound to a protocol stack, but the attack is limited at the protocol level to a logically adjacent topology. This can mean an attack must be launched from the same shared proximity (e.g., Bluetooth, NFC, or IEEE 802.11) or logical network (e.g., local IP subnet), or from within a secure or otherwise limited administrative domain (e.g., MPLS, secure VPN within an administrative network zone).",
"icon": "cvss-adj"
},
"NETWORK": {
"class":"bad",
"title": "Network",
"infoText": "The vulnerable system is bound to the network stack and the set of possible attackers extends beyond the other options listed below, up to and including the entire Internet. Such a vulnerability is often termed \u201cremotely exploitable\u201d and can be thought of as an attack being exploitable at the protocol level one or more network hops away (e.g., across one or more routers).",
"icon": "cvss-net"
}
},
"attackComplexity": {
"title": "Attack Complexity",
"infoText": "This metric captures measurable actions that must be taken by the attacker to actively evade or circumvent existing built-in security-enhancing conditions in order to obtain a working exploit. These are conditions whose primary purpose is to increase security and/or increase exploit engineering complexity. A vulnerability exploitable without a target-specific variable has a lower complexity than a vulnerability that would require non-trivial customization. This metric is meant to capture security mechanisms utilized by the vulnerable system.",
"HIGH": {
"title": "High",
"infoText": "The successful attack depends on the evasion or circumvention of security-enhancing techniques in place that would otherwise hinder the attack. These include: Evasion of exploit mitigation techniques, for example, circumvention of address space randomization (ASLR) or data execution prevention (DEP) must be performed for the attack to be successful; Obtaining target-specific secrets. The attacker must gather some target-specific secret before the attack can be successful. A secret is any piece of information that cannot be obtained through any amount of reconnaissance. To obtain the secret the attacker must perform additional attacks or break otherwise secure measures (e.g. knowledge of a secret key may be needed to break a crypto channel). This operation must be performed for each attacked target.",
"icon": "rocket"
},
"LOW": {
"title": "Low",
"infoText": "The attacker must take no measurable action to exploit the vulnerability. The attack requires no target-specific circumvention to exploit the vulnerability. An attacker can expect repeatable success against the vulnerable system.",
"icon": "paper-plane"
}
},
"attackRequirements": {
"title": "Attack Requirements",
"infoText": "This metric captures the prerequisite deployment and execution conditions or variables of the vulnerable system that enable the attack. These differ from security-enhancing techniques/technologies (ref Attack Complexity) as the primary purpose of these conditions is not to explicitly mitigate attacks, but rather, emerge naturally as a consequence of the deployment and execution of the vulnerable system.",
"PRESENT": {
"title": "Present",
"infoText": "The successful attack depends on the presence of specific deployment and execution conditions of the vulnerable system that enable the attack. These include: a race condition must be won to successfully exploit the vulnerability (the successfulness of the attack is conditioned on execution conditions that are not under full control of the attacker, or the attack may need to be launched multiple times against a single target before being successful); the attacker must inject themselves into the logical network path between the target and the resource requested by the victim (e.g. vulnerabilities requiring an on-path attacker).",
"icon": "cvss-required"
},
"NONE": {
"title": "None",
"infoText": "The successful attack does not depend on the deployment and execution conditions of the vulnerable system. The attacker can expect to be able to reach the vulnerability and execute the exploit under all or most instances of the vulnerability.",
"icon": "cvss-direct"
}
},
"privilegesRequired": {
"title": "Privileges Required",
"infoText": "This metric describes the level of privileges an attacker must possess prior to successfully exploiting the vulnerability. The method by which the attacker obtains privileged credentials prior to the attack (e.g., free trial accounts), is outside the scope of this metric. Generally, self-service provisioned accounts do not constitute a privilege requirement if the attacker can grant themselves privileges as part of the attack.",
"HIGH": {
"title": "High",
"infoText": "The attacker requires privileges that provide significant (e.g., administrative) control over the vulnerable system allowing full access to the vulnerable system\u2019s settings and files.",
"icon": "king"
},
"LOW": {
"title": "Low",
"infoText": "The attacker requires privileges that provide basic capabilities that are typically limited to settings and resources owned by a single low-privileged user. Alternatively, an attacker with Low privileges has the ability to access only non-sensitive resources.",
"icon": "pawn"
},
"NONE": {
"title": "None",
"infoText": "The attacker is unauthorized prior to attack, and therefore does not require any access to settings or files of the vulnerable system to carry out an attack.",
"icon": "thief"
}
},
"userInteraction": {
"title": "User Interaction",
"infoText": "This metric captures the requirement for a human user, other than the attacker, to participate in the successful compromise of the vulnerable system. This metric determines whether the vulnerability can be exploited solely at the will of the attacker, or whether a separate user (or user-initiated process) must participate in some manner.",
"ACTIVE": {
"title": "Active",
"infoText": "Successful exploitation of this vulnerability requires a targeted user to perform specific, conscious interactions with the vulnerable system and the attacker\u2019s payload, or the user\u2019s interactions would actively subvert protection mechanisms which would lead to exploitation of the vulnerability.",
"icon": "alert"
},
"PASSIVE": {
"title": "Passive",
"infoText": "Successful exploitation of this vulnerability requires limited interaction by the targeted user with the vulnerable system and the attacker\u2019s payload. These interactions would be considered involuntary and do not require that the user actively subvert protections built into the vulnerable system.",
"icon": "eye-half"
},
"NONE": {
"title": "None",
"infoText": "The vulnerable system can be exploited without interaction from any human user, other than the attacker.",
"icon": "cvss-direct"
}
},
"confidentialityImpact": {
"title": "Confidentiality",
"infoText": "This metric measures the impact to the confidentiality.",
"NONE": {
"title": "None",
"infoText": "There is no loss of confidentiality.",
"icon": "eye-close"
},
"PARTIAL": {
"title": "Partial",
"infoText": "There is considerable informational disclosure.",
"icon": "eye-half"
},
"COMPLETE": {
"class":"bad",
"title": "Complete",
"infoText": "There is total information disclosure, resulting in all system files being revealed.",
"icon": "eye"
},
"LOW": {
"title": "Low",
"infoText": "There is some loss of confidentiality.",
"icon": "eye-half"
},
"HIGH": {
"class":"bad",
"title": "High",
"infoText": "There is a total loss of confidentiality.",
"icon": "eye"
}
},
"vulnConfidentialityImpact": {
"title": "Product Confidentiality",
"infoText": "This metric measures the impact to the confidentiality of the information managed by the VULNERABLE SYSTEM due to a successfully exploited vulnerability. Confidentiality refers to limiting information access and disclosure to only authorized users, as well as preventing access by, or disclosure to, unauthorized ones.",
"NONE": {