-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathviewer.html
executable file
·145 lines (141 loc) · 6.02 KB
/
viewer.html
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
<html>
<head>
<title>Page title</title>
<script src="tabulator/js/tabulator.min.js"></script>
<link href="tabulator/css/tabulator.min.css" rel="stylesheet">
<style>
:root {
--bg10: #efefef;
--bg-blue-light1: #f6f8fa;
}
.tabulator-row .tabulator-cell {overflow-wrap: break-word !important;text-overflow: unset;padding:5px;line-height: 140%;border-color:#edebef;}
.tabulator {background-color:var(--bg-blue-light1);}
.tabulator-row.tabulator-row-even {background-color: #fff;}
.tabulator-tableholder {padding-left:20px;}
.tabulator-header-contents {padding-left:20px;}
.tabulator .tabulator-tableholder .tabulator-table {background-color:var(--bg-blue-light1);}
.tabulator-row {border:1px solid #AAA;}
.tabulator-group-level-0 { margin-top:22px;overflow-wrap: break-word !important;text-overflow: unset;white-space:pre-wrap;line-height: 140%;padding-top:10px !important;}
.tabulator-row.tabulator-group {border-top-left-radius:5px;background-color:#F7F7F7;}
.tabulator-row.tabulator-group:hover {background-color:#F7F7F7;}
.tabulator-row.tabulator-selectable:hover {background-color:#F7F7F7;}
.tabulator-row {border-top:0px;}
.tabulator-row.tabulator-group .tabulator-arrow {border: solid black;border-width: 0 3px 3px 0;transform: rotate(-45deg);padding:3px;}
.tabulator-row.tabulator-group.tabulator-group-visible .tabulator-arrow {border: solid black;border-width: 0 3px 3px 0;transform: rotate(45deg);padding:3px;}
.tabulator-row.tabulator-group .tabulator-arrow:hover {animation: rotation 1s ease infinite;}
@keyframes rotation {
to {transform: rotate(315deg);}
}
.badge {padding-left:5px;padding-right:5px;padding-top:2px;padding-bottom:3px;border-radius:5px;font-size:120%;}
.lbadge {padding-top:2px;padding-bottom:3px;border-radius:5px;background-color:#eaf1fb;}
.counter {color:#888 !important; margin-left:10px;font-weight: 400;}
.tabulator-row p {font-weight: 400;margin-bottom:5px;margin-top:8px;width:98%;}
.tabulator-row.tabulator-selectable .xmenu {display: none;}
.tabulator-row.tabulator-selectable:hover .xmenu {display: inline-block;}
.xmenu {position: absolute;right: 0;display: inline-block;right: 5px;top: 3px;cursor: pointer;}
</style>
</head>
<body>
<input type="file" id="file-input" />
<br/>
<br/>
<div id="example-table"></div>
<script>
function readSingleFile(e) {
var file = e.target.files[0];
if (!file) {
return;
}
var reader = new FileReader();
reader.onload = function(e) {
var contents = e.target.result;
displayContents(contents);
};
reader.readAsText(file);
}
var _defaultColors = {
accessanalyzer: "#007bff",
ec2: "#6c757d",
apigateway: "#28a745",
elb: "#28a745",
elbv2: "#28a745",
lambda: "#17a2b8",
cloudformation: "#ffa100",
cloudwatch: "#7f43e5",
cloudtrail: "#7f43e5",
ecr: "#0072bc",
iam: "#fc9ab4",
s3: "#41c8c3",
}
function serviceColor(cell, formatterParams, onRendered) {
const v = cell.getValue();
if (_defaultColors.hasOwnProperty(v)) {
return "<span class='badge' style='background-color:"+_defaultColors[v]+";color:#FFF;'>"+v+"</span>";
}
return v;
}
function statusColor(cell, formatterParams, onRendered) {
const v = cell.getValue();
cell.getElement().style.whiteSpace = "pre-wrap";
return "<span class='lbadge'>"+v+"</span>";
}
var _severityColors = {
critical: "#dc3545",
//high: "#e60000",
high: "#fc9ab4",
medium: "#ffa100",
low: "#6c757d",
}
function severityColor(cell, formatterParams, onRendered) {
const v = cell.getValue();
if (_severityColors.hasOwnProperty(v)) {
return "<span class='badge' style='background-color:"+_severityColors[v]+";color:#FFF;'>"+v+"</span>";
}
return v;
}
function displayResource(cell, formatterParams, onRendered) {
const r = cell.getRow().getData();
cell.getElement().style.whiteSpace = "pre-wrap";
//console.log(r);
return r.Region +" "+r.ResourceType+"<br/>"+r.ResourceId+"<br/>"+r.ResourceArn;
}
function displayStatus(cell, formatterParams, onRendered) {
const r = cell.getValue();
//cell.getElement().style.whiteSpace = "pre-wrap";
return r+"<div class='xmenu'><svg fill='#000000' width='24px' height='24px' viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'><path d='M48,48V208H80a8,8,0,0,1,0,16H40a8.00039,8.00039,0,0,1-8-8V40a8.00039,8.00039,0,0,1,8-8H80a8,8,0,0,1,0,16ZM216,32H176a8,8,0,0,0,0,16h32V208H176a8,8,0,0,0,0,16h40a8.00039,8.00039,0,0,0,8-8V40A8.00039,8.00039,0,0,0,216,32Z' /></svg></div>";
}
function displayContents(contents) {
//initialize table
var table = new Tabulator("#example-table", {
data:JSON.parse(contents), //assign data to table
//ajaxURL:"prowler.json"
//autoColumns:true, //create columns from data field names
layout:"fitColumns",
groupBy: "Description",
groupHeader: function(value, count, data, group){
//console.log(data[0]["Risk"]);
return "<span class='badge' style='background-color:#007bff;color:#FFF;'>"+value + "</span> <span class='counter'>Count: " + count + "</span><p>"+data[0]["Risk"]+"</p>";
},
placeholder:"Awaiting Data, Please Load File",
columns:[
{title: "Status", field: "Status", formatter: displayStatus, width:80},
{title: "Service", field: "ServiceName", formatter: serviceColor, width:120},
//{title: "CheckID", field: "CheckID", formatter: "textarea", width:250},
//{title: "CheckType", field: "CheckType", formatter: "textarea"},
{title: "Issue", field: "StatusExtended", formatter: statusColor},
{title: "Severity", field: "Severity", formatter: severityColor, width:90},
//{title: "ResourceType", field: "ResourceType", width:100, formatter: "textarea"},
//{title: "Description", field: "Description", formatter: "textarea"},
//{title: "Risk", field: "Risk", formatter: "textarea", width:'50%'},
{title: "Resource", formatter:displayResource, width:500},
//{title: "Region", field: "Region"},
//{title: "ResourceId", field: "ResourceId"},
//{title: "ResourceArn", field: "ResourceArn", formatter: "textarea"},
]
});
}
document.getElementById('file-input')
.addEventListener('change', readSingleFile, false);
</script>
</body>
</html>