/
stats.js
57 lines (50 loc) · 2.02 KB
/
stats.js
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
/*
* Copyright (c) 2019 Renata Hodovan, Akos Kiss.
*
* Licensed under the BSD 3-Clause License
* <LICENSE.rst or https://opensource.org/licenses/BSD-3-Clause>.
* This file may not be copied, modified, or distributed except
* according to those terms.
*/
/* global fz */
$(document).ready(function () {
'use strict';
$('#stats-tab').addClass('active');
function statRowFormatter (value, data) {
var statRow = document.importNode($('#stat-card-template').prop('content').cloneNode(true), true).children[0];
$(statRow).find('.fuzzer').text(data.fuzzer);
$(statRow).find('.exec').text(data.exec);
$(statRow).find('.issues').text(data.issues);
$(statRow).find('.unique').text(data.unique);
return $(statRow)[0].outerHTML;
}
function statRowDetailFormatter (index, row) {
var mainDiv = document.createElement('div');
for (var detail of row.subconfigs) {
var statRowDetail = document.importNode($('#stat-row-template').prop('content').cloneNode(true), true).children[0];
if (detail.subconfig !== null) {
$(statRowDetail).find('.config-ref').attr('href', `/configs/${detail.subconfig}`);
}
$(statRowDetail).find('.config-ref').text(detail.subconfig === null ? 'N/A' : `${detail.subconfig}`);
$(statRowDetail).find('.sut').text(row.sut);
$(statRowDetail).find('.exec').text(detail.exec);
$(statRowDetail).find('.issues').text(detail.issues);
$(statRowDetail).find('.unique').text(detail.unique);
$(statRowDetail).appendTo($(mainDiv));
}
return mainDiv.outerHTML;
}
var bst = $('#stats-table').bootstrapTable(fz.utils.bstOptions({
columnNames: ['fuzzer', 'exec', 'issues', 'unique', 'sut'],
formatter: statRowFormatter,
detailFormatter: statRowDetailFormatter,
sortName: 'exec',
sortOrder: 'desc',
cookieIdTable: 'statTableCookie',
getRows: fz.api.getStats,
showAll: true,
})).data()['bootstrap.table'];
fz.notifications.onmessage['refresh_stats'] = function () {
bst.refresh({ silent: true });
};
});