cloudg 0.3.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- cloudg/__init__.py +21 -0
- cloudg/api.py +613 -0
- cloudg/cli.py +934 -0
- cloudg/collectors/__init__.py +5 -0
- cloudg/collectors/aws.py +830 -0
- cloudg/collectors/azure.py +362 -0
- cloudg/collectors/base.py +44 -0
- cloudg/collectors/gcp.py +170 -0
- cloudg/collectors/multi.py +329 -0
- cloudg/config.py +261 -0
- cloudg/coverage.py +93 -0
- cloudg/credentials.py +451 -0
- cloudg/graph/__init__.py +6 -0
- cloudg/graph/builder.py +336 -0
- cloudg/graph/ontology.py +914 -0
- cloudg/graph/rag_export.py +533 -0
- cloudg/graph/reachability.py +237 -0
- cloudg/normaliser.py +390 -0
- cloudg/policies/custodian-aws-security.yml +139 -0
- cloudg/policies/custodian-azure.yml +95 -0
- cloudg/policies/custodian-gcp.yml +87 -0
- cloudg/policies/custodian.yml +131 -0
- cloudg/region_discovery.py +330 -0
- cloudg/registry.py +142 -0
- cloudg/renderers/__init__.py +1 -0
- cloudg/renderers/html_report.py +430 -0
- cloudg/renderers/json_export.py +65 -0
- cloudg/renderers/svg.py +689 -0
- cloudg/renderers/terraform_export.py +666 -0
- cloudg/retry.py +103 -0
- cloudg/rules/cis_aws_v3.yaml +148 -0
- cloudg/rules/cis_azure_v2.yaml +142 -0
- cloudg/rules/cis_gcp_v3.yaml +133 -0
- cloudg/rules/frameworks/aws_foundational_security_best_practices_aws.yaml +1286 -0
- cloudg/rules/frameworks/cis_5.0_aws.yaml +280 -0
- cloudg/rules/frameworks/cis_5.0_azure.yaml +475 -0
- cloudg/rules/frameworks/cis_5.0_gcp.yaml +327 -0
- cloudg/rules/frameworks/gdpr_aws.yaml +95 -0
- cloudg/rules/frameworks/hipaa_aws.yaml +461 -0
- cloudg/rules/frameworks/hipaa_azure.yaml +504 -0
- cloudg/rules/frameworks/hipaa_gcp.yaml +211 -0
- cloudg/rules/frameworks/iso27001_2022_aws.yaml +789 -0
- cloudg/rules/frameworks/iso27001_2022_azure.yaml +477 -0
- cloudg/rules/frameworks/iso27001_2022_gcp.yaml +240 -0
- cloudg/rules/frameworks/mitre_attack_aws.yaml +596 -0
- cloudg/rules/frameworks/mitre_attack_azure.yaml +418 -0
- cloudg/rules/frameworks/mitre_attack_gcp.yaml +300 -0
- cloudg/rules/frameworks/nist_800_53_revision_5_aws.yaml +3234 -0
- cloudg/rules/frameworks/nist_csf_2.0_aws.yaml +828 -0
- cloudg/rules/frameworks/pci_4.0_aws.yaml +7108 -0
- cloudg/rules/frameworks/pci_4.0_azure.yaml +4696 -0
- cloudg/rules/frameworks/pci_4.0_gcp.yaml +5405 -0
- cloudg/rules/frameworks/soc2_aws.yaml +421 -0
- cloudg/rules/frameworks/soc2_azure.yaml +477 -0
- cloudg/rules/frameworks/soc2_gcp.yaml +342 -0
- cloudg/rules/gdpr.yaml +56 -0
- cloudg/rules/hipaa_security_rule.yaml +83 -0
- cloudg/rules/iso_27001_2022.yaml +88 -0
- cloudg/rules/nist_800_53.yaml +134 -0
- cloudg/rules/pci_dss_v4.yaml +108 -0
- cloudg/rules/soc2_tsc.yaml +93 -0
- cloudg/scanners/__init__.py +1 -0
- cloudg/scanners/checkov.py +174 -0
- cloudg/scanners/iam_linter.py +200 -0
- cloudg/scanners/prowler.py +237 -0
- cloudg/scanners/scoutsuite.py +163 -0
- cloudg/scanners/trivy.py +339 -0
- cloudg/schema/__init__.py +25 -0
- cloudg/schema/models.py +260 -0
- cloudg/templates/report.html.j2 +828 -0
- cloudg-0.3.0.dist-info/METADATA +330 -0
- cloudg-0.3.0.dist-info/RECORD +75 -0
- cloudg-0.3.0.dist-info/WHEEL +4 -0
- cloudg-0.3.0.dist-info/entry_points.txt +14 -0
- cloudg-0.3.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,828 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
+
<title>CloudG Security Report</title>
|
|
7
|
+
<meta name="description" content="Cloud Infrastructure Security Assessment Report generated by CloudG">
|
|
8
|
+
<style>
|
|
9
|
+
/* ── Reset & Base ── */
|
|
10
|
+
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
|
|
11
|
+
|
|
12
|
+
:root {
|
|
13
|
+
--bg-primary: #0F172A;
|
|
14
|
+
--bg-secondary: #1E293B;
|
|
15
|
+
--bg-tertiary: #334155;
|
|
16
|
+
--text-primary: #F8FAFC;
|
|
17
|
+
--text-secondary: #CBD5E1;
|
|
18
|
+
--text-muted: #94A3B8;
|
|
19
|
+
--border: #334155;
|
|
20
|
+
--accent: #6366F1;
|
|
21
|
+
--accent-hover: #4F46E5;
|
|
22
|
+
--critical: #EF4444;
|
|
23
|
+
--high: #F97316;
|
|
24
|
+
--medium: #EAB308;
|
|
25
|
+
--low: #3498DB;
|
|
26
|
+
--info: #64748B;
|
|
27
|
+
--success: #22C55E;
|
|
28
|
+
--radius: 12px;
|
|
29
|
+
--shadow: 0 4px 6px -1px rgba(0,0,0,0.3), 0 2px 4px -2px rgba(0,0,0,0.2);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
body {
|
|
33
|
+
font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
|
|
34
|
+
background: var(--bg-primary);
|
|
35
|
+
color: var(--text-secondary);
|
|
36
|
+
line-height: 1.6;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/* ── Layout ── */
|
|
40
|
+
.container { max-width: 1500px; margin: 0 auto; padding: 24px; }
|
|
41
|
+
|
|
42
|
+
.header {
|
|
43
|
+
display: flex; justify-content: space-between; align-items: center;
|
|
44
|
+
padding: 24px 0; border-bottom: 1px solid var(--border); margin-bottom: 30px;
|
|
45
|
+
}
|
|
46
|
+
.header h1 { font-size: 28px; color: var(--text-primary); font-weight: 700; }
|
|
47
|
+
.header .meta { color: var(--text-muted); font-size: 13px; }
|
|
48
|
+
|
|
49
|
+
/* ── Cards Grid ── */
|
|
50
|
+
.stats-grid {
|
|
51
|
+
display: grid;
|
|
52
|
+
grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
|
|
53
|
+
gap: 16px; margin-bottom: 32px;
|
|
54
|
+
}
|
|
55
|
+
.stat-card {
|
|
56
|
+
background: var(--bg-secondary); border: 1px solid var(--border);
|
|
57
|
+
border-radius: var(--radius); padding: 20px;
|
|
58
|
+
transition: transform 0.2s, box-shadow 0.2s;
|
|
59
|
+
}
|
|
60
|
+
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
|
|
61
|
+
.stat-card .label {
|
|
62
|
+
font-size: 11px; text-transform: uppercase; letter-spacing: 1.5px;
|
|
63
|
+
color: var(--text-muted); margin-bottom: 8px;
|
|
64
|
+
}
|
|
65
|
+
.stat-card .value { font-size: 32px; font-weight: 800; color: var(--text-primary); }
|
|
66
|
+
.stat-card.critical .value { color: var(--critical); }
|
|
67
|
+
.stat-card.high .value { color: var(--high); }
|
|
68
|
+
.stat-card.medium .value { color: var(--medium); }
|
|
69
|
+
.stat-card.low .value { color: var(--low); }
|
|
70
|
+
|
|
71
|
+
/* ── Tabs ── */
|
|
72
|
+
.tabs {
|
|
73
|
+
display: flex; gap: 4px; margin-bottom: 24px;
|
|
74
|
+
background: var(--bg-secondary); border-radius: var(--radius);
|
|
75
|
+
padding: 4px; border: 1px solid var(--border);
|
|
76
|
+
}
|
|
77
|
+
.tab {
|
|
78
|
+
padding: 10px 20px; border-radius: 8px; cursor: pointer;
|
|
79
|
+
font-size: 14px; font-weight: 500; color: var(--text-muted);
|
|
80
|
+
transition: all 0.2s; border: none; background: none;
|
|
81
|
+
}
|
|
82
|
+
.tab:hover { color: var(--text-primary); background: var(--bg-tertiary); }
|
|
83
|
+
.tab.active { background: var(--accent); color: white; }
|
|
84
|
+
|
|
85
|
+
.tab-content { display: none; }
|
|
86
|
+
.tab-content.active { display: block; }
|
|
87
|
+
|
|
88
|
+
/* ── Charts ── */
|
|
89
|
+
.charts-row {
|
|
90
|
+
display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 30px;
|
|
91
|
+
}
|
|
92
|
+
.chart-card {
|
|
93
|
+
background: var(--bg-secondary); border: 1px solid var(--border);
|
|
94
|
+
border-radius: var(--radius); padding: 24px;
|
|
95
|
+
}
|
|
96
|
+
.chart-card h3 { color: var(--text-primary); font-size: 16px; margin-bottom: 16px; }
|
|
97
|
+
.chart-card canvas { max-height: 300px; }
|
|
98
|
+
|
|
99
|
+
/* ── Topology ── */
|
|
100
|
+
#topology-container {
|
|
101
|
+
background: var(--bg-secondary); border: 1px solid var(--border);
|
|
102
|
+
border-radius: var(--radius); overflow: hidden; min-height: 600px;
|
|
103
|
+
position: relative;
|
|
104
|
+
}
|
|
105
|
+
#topology-container svg { width: 100%; height: 600px; }
|
|
106
|
+
.topo-legend {
|
|
107
|
+
position: absolute; top: 16px; right: 16px;
|
|
108
|
+
background: rgba(15,23,42,0.9); border: 1px solid var(--border);
|
|
109
|
+
border-radius: 8px; padding: 12px 16px; font-size: 12px;
|
|
110
|
+
backdrop-filter: blur(4px); z-index: 10;
|
|
111
|
+
}
|
|
112
|
+
.topo-legend .legend-item { display: flex; align-items: center; gap: 8px; margin: 4px 0; }
|
|
113
|
+
.topo-legend .legend-dot {
|
|
114
|
+
width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0;
|
|
115
|
+
}
|
|
116
|
+
.topo-controls {
|
|
117
|
+
position: absolute; top: 16px; left: 16px; display: flex; gap: 8px; z-index: 10;
|
|
118
|
+
}
|
|
119
|
+
.topo-controls button {
|
|
120
|
+
background: rgba(15,23,42,0.9); border: 1px solid var(--border);
|
|
121
|
+
color: var(--text-secondary); padding: 6px 12px; border-radius: 6px;
|
|
122
|
+
cursor: pointer; font-size: 13px; backdrop-filter: blur(4px);
|
|
123
|
+
}
|
|
124
|
+
.topo-controls button:hover { background: var(--accent); color: white; }
|
|
125
|
+
|
|
126
|
+
/* ── Findings Table ── */
|
|
127
|
+
.table-controls {
|
|
128
|
+
display: flex; gap: 12px; margin-bottom: 16px; flex-wrap: wrap;
|
|
129
|
+
}
|
|
130
|
+
.table-controls select, .table-controls input {
|
|
131
|
+
background: var(--bg-secondary); border: 1px solid var(--border);
|
|
132
|
+
color: var(--text-secondary); padding: 8px 14px; border-radius: 8px;
|
|
133
|
+
font-size: 14px; outline: none;
|
|
134
|
+
}
|
|
135
|
+
.table-controls select:focus, .table-controls input:focus {
|
|
136
|
+
border-color: var(--accent);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
table { width: 100%; border-collapse: collapse; }
|
|
140
|
+
thead { background: var(--bg-tertiary); }
|
|
141
|
+
th {
|
|
142
|
+
padding: 12px 16px; text-align: left; font-size: 11px;
|
|
143
|
+
text-transform: uppercase; letter-spacing: 1px; color: var(--text-muted);
|
|
144
|
+
font-weight: 600;
|
|
145
|
+
}
|
|
146
|
+
td {
|
|
147
|
+
padding: 12px 16px; border-bottom: 1px solid var(--border);
|
|
148
|
+
font-size: 14px; vertical-align: top;
|
|
149
|
+
}
|
|
150
|
+
tr { transition: background 0.15s; cursor: pointer; }
|
|
151
|
+
tr:hover { background: var(--bg-tertiary); }
|
|
152
|
+
|
|
153
|
+
.severity-badge {
|
|
154
|
+
display: inline-block; padding: 2px 10px; border-radius: 20px;
|
|
155
|
+
font-size: 11px; font-weight: 700; text-transform: uppercase;
|
|
156
|
+
}
|
|
157
|
+
.severity-CRITICAL { background: rgba(239,68,68,0.15); color: var(--critical); }
|
|
158
|
+
.severity-HIGH { background: rgba(249,115,22,0.15); color: var(--high); }
|
|
159
|
+
.severity-MEDIUM { background: rgba(234,179,8,0.15); color: var(--medium); }
|
|
160
|
+
.severity-LOW { background: rgba(52,152,219,0.15); color: var(--low); }
|
|
161
|
+
.severity-INFO { background: rgba(100,116,139,0.15); color: var(--info); }
|
|
162
|
+
|
|
163
|
+
code { background: var(--bg-tertiary); padding: 2px 6px; border-radius: 4px; font-size: 12px; }
|
|
164
|
+
|
|
165
|
+
/* ── Detail Panel ── */
|
|
166
|
+
.detail-panel {
|
|
167
|
+
display: none; position: fixed; top: 0; right: 0;
|
|
168
|
+
width: 500px; height: 100vh; background: var(--bg-secondary);
|
|
169
|
+
border-left: 1px solid var(--border); z-index: 1000;
|
|
170
|
+
overflow-y: auto; padding: 24px; box-shadow: -4px 0 20px rgba(0,0,0,0.4);
|
|
171
|
+
}
|
|
172
|
+
.detail-panel.open { display: block; }
|
|
173
|
+
.detail-panel .close-btn {
|
|
174
|
+
position: absolute; top: 16px; right: 16px;
|
|
175
|
+
background: var(--bg-tertiary); border: none; color: var(--text-secondary);
|
|
176
|
+
width: 32px; height: 32px; border-radius: 8px; cursor: pointer;
|
|
177
|
+
font-size: 18px; display: flex; align-items: center; justify-content: center;
|
|
178
|
+
}
|
|
179
|
+
.detail-panel h2 { font-size: 18px; color: var(--text-primary); margin-bottom: 20px; padding-right: 40px; }
|
|
180
|
+
.detail-field { margin-bottom: 16px; }
|
|
181
|
+
.detail-field .label { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--text-muted); margin-bottom: 4px; }
|
|
182
|
+
.detail-field .value { color: var(--text-secondary); font-size: 14px; }
|
|
183
|
+
.detail-field pre { background: var(--bg-primary); padding: 12px; border-radius: 8px; font-size: 12px; overflow-x: auto; color: var(--text-secondary); }
|
|
184
|
+
|
|
185
|
+
/* ── Compliance ── */
|
|
186
|
+
.compliance-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 16px; }
|
|
187
|
+
.compliance-card {
|
|
188
|
+
background: var(--bg-secondary); border: 1px solid var(--border);
|
|
189
|
+
border-radius: var(--radius); padding: 20px;
|
|
190
|
+
}
|
|
191
|
+
.compliance-card h4 { color: var(--text-primary); margin-bottom: 12px; }
|
|
192
|
+
.compliance-bar { height: 8px; background: var(--bg-tertiary); border-radius: 4px; overflow: hidden; margin-top: 8px; }
|
|
193
|
+
.compliance-bar-fill { height: 100%; border-radius: 4px; transition: width 0.8s ease; }
|
|
194
|
+
|
|
195
|
+
/* ── Export Button ── */
|
|
196
|
+
.btn-export {
|
|
197
|
+
background: var(--accent); color: white; border: none;
|
|
198
|
+
padding: 10px 20px; border-radius: 8px; cursor: pointer;
|
|
199
|
+
font-weight: 600; font-size: 14px; transition: background 0.2s;
|
|
200
|
+
}
|
|
201
|
+
.btn-export:hover { background: var(--accent-hover); }
|
|
202
|
+
|
|
203
|
+
@media (max-width: 768px) {
|
|
204
|
+
.charts-row { grid-template-columns: 1fr; }
|
|
205
|
+
.header { flex-direction: column; align-items: flex-start; gap: 12px; }
|
|
206
|
+
.detail-panel { width: 100%; }
|
|
207
|
+
}
|
|
208
|
+
</style>
|
|
209
|
+
<!-- Chart.js 4 (self-contained) -->
|
|
210
|
+
<script src="https://cdn.jsdelivr.net/npm/chart.js@4.4.0/dist/chart.umd.min.js"></script>
|
|
211
|
+
<!-- D3.js v7 -->
|
|
212
|
+
<script src="https://cdn.jsdelivr.net/npm/d3@7/dist/d3.min.js"></script>
|
|
213
|
+
</head>
|
|
214
|
+
<body>
|
|
215
|
+
|
|
216
|
+
<div class="container">
|
|
217
|
+
<!-- Header -->
|
|
218
|
+
<div class="header">
|
|
219
|
+
<div>
|
|
220
|
+
<h1>☁️ CloudG Security Report</h1>
|
|
221
|
+
<p class="meta">Scan: {{ scan_id }} · Provider: {{ provider }} · Account: {{ account_id }} · {{ started_at }}</p>
|
|
222
|
+
</div>
|
|
223
|
+
<button class="btn-export" onclick="exportJSON()">⬇ Export JSON</button>
|
|
224
|
+
</div>
|
|
225
|
+
|
|
226
|
+
<!-- Stats Cards -->
|
|
227
|
+
<div class="stats-grid">
|
|
228
|
+
<div class="stat-card"><div class="label">Total Assets</div><div class="value">{{ total_assets }}</div></div>
|
|
229
|
+
<div class="stat-card"><div class="label">Total Findings</div><div class="value">{{ total_findings }}</div></div>
|
|
230
|
+
<div class="stat-card critical"><div class="label">Critical</div><div class="value">{{ severity_counts.CRITICAL }}</div></div>
|
|
231
|
+
<div class="stat-card high"><div class="label">High</div><div class="value">{{ severity_counts.HIGH }}</div></div>
|
|
232
|
+
<div class="stat-card medium"><div class="label">Medium</div><div class="value">{{ severity_counts.MEDIUM }}</div></div>
|
|
233
|
+
<div class="stat-card low"><div class="label">Low</div><div class="value">{{ severity_counts.LOW }}</div></div>
|
|
234
|
+
</div>
|
|
235
|
+
|
|
236
|
+
<!-- Tabs -->
|
|
237
|
+
<div class="tabs" id="main-tabs">
|
|
238
|
+
<button class="tab active" onclick="switchTab('topology')">Infrastructure Map</button>
|
|
239
|
+
<button class="tab" onclick="switchTab('findings')">Findings</button>
|
|
240
|
+
<button class="tab" onclick="switchTab('charts')">Analytics</button>
|
|
241
|
+
<button class="tab" onclick="switchTab('compliance')">Compliance</button>
|
|
242
|
+
</div>
|
|
243
|
+
|
|
244
|
+
<!-- Tab: Topology -->
|
|
245
|
+
<div class="tab-content active" id="tab-topology">
|
|
246
|
+
<div id="topology-container">
|
|
247
|
+
<div class="topo-controls">
|
|
248
|
+
<button onclick="toggleLayout()">🔄 Toggle Layout</button>
|
|
249
|
+
<button onclick="resetZoom()">⊞ Reset Zoom</button>
|
|
250
|
+
<button onclick="expandAll()">▸ Expand All</button>
|
|
251
|
+
<button onclick="collapseAll()">◂ Collapse</button>
|
|
252
|
+
</div>
|
|
253
|
+
<div class="topo-legend">
|
|
254
|
+
<div style="font-weight:600;margin-bottom:6px;color:var(--text-primary)">Legend</div>
|
|
255
|
+
<div class="legend-item"><div class="legend-dot" style="background:#6366F1"></div>Account</div>
|
|
256
|
+
<div class="legend-item"><div class="legend-dot" style="background:#22C55E"></div>Region</div>
|
|
257
|
+
<div class="legend-item"><div class="legend-dot" style="background:#4A90D9"></div>VPC</div>
|
|
258
|
+
<div class="legend-item"><div class="legend-dot" style="background:#7EC8E3"></div>Subnet</div>
|
|
259
|
+
<div class="legend-item"><div class="legend-dot" style="background:#FF9900"></div>Compute</div>
|
|
260
|
+
<div class="legend-item"><div class="legend-dot" style="background:#569A31"></div>Storage</div>
|
|
261
|
+
<div class="legend-item"><div class="legend-dot" style="background:#8C4FFF"></div>Security</div>
|
|
262
|
+
<div class="legend-item"><div class="legend-dot" style="background:#95A5A6"></div>Other</div>
|
|
263
|
+
<div class="legend-item" style="margin-top:8px"><div class="legend-dot" style="background:transparent;border:2px solid #EF4444"></div>Has Findings</div>
|
|
264
|
+
<div class="legend-item"><div class="legend-dot" style="background:transparent;border:2px solid #FF9900"></div>Internet Exposed</div>
|
|
265
|
+
<div class="legend-item" style="margin-top:8px;font-weight:600;color:var(--text-primary)">Ontology Entities</div>
|
|
266
|
+
<div class="legend-item"><div class="legend-dot" style="background:#EF4444;clip-path:polygon(50% 0%,100% 100%,0% 100%)"></div>Security Finding (▲)</div>
|
|
267
|
+
<div class="legend-item"><div class="legend-dot" style="background:#14B8A6;clip-path:polygon(50% 0%,100% 50%,50% 100%,0% 50%)"></div>Compliance Framework (◆)</div>
|
|
268
|
+
<div class="legend-item" style="margin-top:4px;font-size:11px;color:var(--text-muted)">─ ─ FINDING_AFFECTS</div>
|
|
269
|
+
<div class="legend-item" style="font-size:11px;color:var(--text-muted)">─ ─ COMPLIANCE_GOVERNS</div>
|
|
270
|
+
</div>
|
|
271
|
+
</div>
|
|
272
|
+
</div>
|
|
273
|
+
|
|
274
|
+
<!-- Tab: Findings -->
|
|
275
|
+
<div class="tab-content" id="tab-findings">
|
|
276
|
+
<div class="table-controls">
|
|
277
|
+
<select id="filter-severity" onchange="filterFindings()">
|
|
278
|
+
<option value="">All Severities</option>
|
|
279
|
+
<option value="CRITICAL">Critical</option>
|
|
280
|
+
<option value="HIGH">High</option>
|
|
281
|
+
<option value="MEDIUM">Medium</option>
|
|
282
|
+
<option value="LOW">Low</option>
|
|
283
|
+
<option value="INFO">Info</option>
|
|
284
|
+
</select>
|
|
285
|
+
<select id="filter-source" onchange="filterFindings()">
|
|
286
|
+
<option value="">All Sources</option>
|
|
287
|
+
</select>
|
|
288
|
+
<input type="text" id="filter-search" placeholder="Search findings..." oninput="filterFindings()">
|
|
289
|
+
</div>
|
|
290
|
+
<table>
|
|
291
|
+
<thead>
|
|
292
|
+
<tr>
|
|
293
|
+
<th>Severity</th>
|
|
294
|
+
<th>Title</th>
|
|
295
|
+
<th>Resource</th>
|
|
296
|
+
<th>Source</th>
|
|
297
|
+
<th>Risk Score</th>
|
|
298
|
+
</tr>
|
|
299
|
+
</thead>
|
|
300
|
+
<tbody id="findings-body"></tbody>
|
|
301
|
+
</table>
|
|
302
|
+
</div>
|
|
303
|
+
|
|
304
|
+
<!-- Tab: Charts -->
|
|
305
|
+
<div class="tab-content" id="tab-charts">
|
|
306
|
+
<div class="charts-row">
|
|
307
|
+
<div class="chart-card">
|
|
308
|
+
<h3>Severity Distribution</h3>
|
|
309
|
+
<canvas id="chart-severity"></canvas>
|
|
310
|
+
</div>
|
|
311
|
+
<div class="chart-card">
|
|
312
|
+
<h3>Resource Types</h3>
|
|
313
|
+
<canvas id="chart-resources"></canvas>
|
|
314
|
+
</div>
|
|
315
|
+
</div>
|
|
316
|
+
<div class="charts-row">
|
|
317
|
+
<div class="chart-card">
|
|
318
|
+
<h3>Findings by Source</h3>
|
|
319
|
+
<canvas id="chart-sources"></canvas>
|
|
320
|
+
</div>
|
|
321
|
+
<div class="chart-card">
|
|
322
|
+
<h3>Compliance Overview</h3>
|
|
323
|
+
<canvas id="chart-compliance"></canvas>
|
|
324
|
+
</div>
|
|
325
|
+
</div>
|
|
326
|
+
</div>
|
|
327
|
+
|
|
328
|
+
<!-- Tab: Compliance -->
|
|
329
|
+
<div class="tab-content" id="tab-compliance">
|
|
330
|
+
<div class="compliance-grid" id="compliance-grid"></div>
|
|
331
|
+
</div>
|
|
332
|
+
</div>
|
|
333
|
+
|
|
334
|
+
<!-- Detail Panel -->
|
|
335
|
+
<div class="detail-panel" id="detail-panel">
|
|
336
|
+
<button class="close-btn" onclick="closeDetail()">×</button>
|
|
337
|
+
<div id="detail-content"></div>
|
|
338
|
+
</div>
|
|
339
|
+
|
|
340
|
+
<script>
|
|
341
|
+
// ── Data ──
|
|
342
|
+
const graphData = {{ graph_json|safe }};
|
|
343
|
+
const hierarchyData = {{ hierarchy_json|safe }};
|
|
344
|
+
const findingsData = {{ findings_json|safe }};
|
|
345
|
+
const findingsPerResource = {{ findings_per_resource_json|safe }};
|
|
346
|
+
const severityCounts = {{ severity_counts_json|safe }};
|
|
347
|
+
const resourceTypes = {{ resource_types_json|safe }};
|
|
348
|
+
const sourceTools = {{ source_tools_json|safe }};
|
|
349
|
+
const complianceSummary = {{ compliance_summary_json|safe }};
|
|
350
|
+
|
|
351
|
+
let currentLayout = 'tree'; // 'tree' or 'force'
|
|
352
|
+
|
|
353
|
+
// ── Tab Switching ──
|
|
354
|
+
function switchTab(tabId) {
|
|
355
|
+
document.querySelectorAll('.tab-content').forEach(el => el.classList.remove('active'));
|
|
356
|
+
document.querySelectorAll('.tab').forEach(el => el.classList.remove('active'));
|
|
357
|
+
document.getElementById('tab-' + tabId).classList.add('active');
|
|
358
|
+
event.target.classList.add('active');
|
|
359
|
+
if (tabId === 'topology') {
|
|
360
|
+
setTimeout(() => renderTopology(), 50);
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
// ── Findings Table ──
|
|
365
|
+
function renderFindings(data) {
|
|
366
|
+
const tbody = document.getElementById('findings-body');
|
|
367
|
+
tbody.innerHTML = data.map((f, i) => `
|
|
368
|
+
<tr onclick="showDetail(${i})">
|
|
369
|
+
<td><span class="severity-badge severity-${f.severity}">${f.severity}</span></td>
|
|
370
|
+
<td>${f.title}</td>
|
|
371
|
+
<td><code>${f.resource_arn || f.resource_id || ''}</code></td>
|
|
372
|
+
<td>${f.source_tool}</td>
|
|
373
|
+
<td>${f.risk_score || '-'}</td>
|
|
374
|
+
</tr>
|
|
375
|
+
`).join('');
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
function filterFindings() {
|
|
379
|
+
const severity = document.getElementById('filter-severity').value;
|
|
380
|
+
const source = document.getElementById('filter-source').value;
|
|
381
|
+
const search = document.getElementById('filter-search').value.toLowerCase();
|
|
382
|
+
let filtered = findingsData;
|
|
383
|
+
if (severity) filtered = filtered.filter(f => f.severity === severity);
|
|
384
|
+
if (source) filtered = filtered.filter(f => f.source_tool === source);
|
|
385
|
+
if (search) filtered = filtered.filter(f =>
|
|
386
|
+
f.title.toLowerCase().includes(search) ||
|
|
387
|
+
(f.resource_arn || '').toLowerCase().includes(search) ||
|
|
388
|
+
(f.description || '').toLowerCase().includes(search)
|
|
389
|
+
);
|
|
390
|
+
renderFindings(filtered);
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
// Populate source filter
|
|
394
|
+
const sourceSelect = document.getElementById('filter-source');
|
|
395
|
+
Object.keys(sourceTools).forEach(tool => {
|
|
396
|
+
const opt = document.createElement('option');
|
|
397
|
+
opt.value = tool; opt.textContent = tool;
|
|
398
|
+
sourceSelect.appendChild(opt);
|
|
399
|
+
});
|
|
400
|
+
|
|
401
|
+
// ── Detail Panel ──
|
|
402
|
+
function showDetail(index) {
|
|
403
|
+
const f = findingsData[index];
|
|
404
|
+
const panel = document.getElementById('detail-panel');
|
|
405
|
+
const content = document.getElementById('detail-content');
|
|
406
|
+
content.innerHTML = `
|
|
407
|
+
<h2>${f.title}</h2>
|
|
408
|
+
<div class="detail-field"><div class="label">Severity</div><div class="value"><span class="severity-badge severity-${f.severity}">${f.severity}</span></div></div>
|
|
409
|
+
<div class="detail-field"><div class="label">Resource</div><div class="value"><code>${f.resource_arn || f.resource_id || 'N/A'}</code></div></div>
|
|
410
|
+
<div class="detail-field"><div class="label">Description</div><div class="value">${f.description || 'N/A'}</div></div>
|
|
411
|
+
<div class="detail-field"><div class="label">Evidence</div><div class="value"><pre>${f.evidence || 'N/A'}</pre></div></div>
|
|
412
|
+
<div class="detail-field"><div class="label">Remediation</div><div class="value">${f.remediation || 'N/A'}</div></div>
|
|
413
|
+
<div class="detail-field"><div class="label">Source Tool</div><div class="value">${f.source_tool}</div></div>
|
|
414
|
+
<div class="detail-field"><div class="label">CVSS Score</div><div class="value">${f.cvss_score || 'N/A'}</div></div>
|
|
415
|
+
<div class="detail-field"><div class="label">Compliance Frameworks</div><div class="value">${(f.compliance_frameworks || []).join(', ') || 'N/A'}</div></div>
|
|
416
|
+
<div class="detail-field"><div class="label">Risk Score</div><div class="value">${f.risk_score || 'N/A'}</div></div>
|
|
417
|
+
`;
|
|
418
|
+
panel.classList.add('open');
|
|
419
|
+
}
|
|
420
|
+
function closeDetail() { document.getElementById('detail-panel').classList.remove('open'); }
|
|
421
|
+
|
|
422
|
+
// ── Hierarchical Topology ──
|
|
423
|
+
const typeColors = {
|
|
424
|
+
account: '#6366F1', region: '#22C55E', vpc: '#4A90D9', vnet: '#4A90D9',
|
|
425
|
+
subnet: '#7EC8E3', global: '#8B5CF6',
|
|
426
|
+
EC2: '#FF9900', VIRTUAL_MACHINE: '#FF9900', GCE_INSTANCE: '#FF9900',
|
|
427
|
+
VPC: '#4A90D9', VNET: '#4A90D9', SUBNET: '#7EC8E3',
|
|
428
|
+
RDS_INSTANCE: '#3B48CC', AURORA_CLUSTER: '#3B48CC', AZURE_SQL: '#3B48CC', CLOUD_SQL: '#3B48CC',
|
|
429
|
+
S3_BUCKET: '#569A31', BLOB_STORAGE: '#569A31', GCS_BUCKET: '#569A31',
|
|
430
|
+
SECURITY_GROUP: '#DD4B39', NSG: '#DD4B39', NACL: '#DD4B39',
|
|
431
|
+
LOAD_BALANCER: '#8C4FFF', CLOUDFRONT: '#8C4FFF',
|
|
432
|
+
IAM_USER: '#F472B6', IAM_ROLE: '#F472B6', IAM_POLICY: '#F472B6',
|
|
433
|
+
LAMBDA_FUNCTION: '#FF9900', CLOUD_FUNCTION: '#FF9900',
|
|
434
|
+
KMS_KEY: '#14B8A6', SECRET: '#14B8A6',
|
|
435
|
+
EBS_VOLUME: '#569A31', DYNAMODB_TABLE: '#3B48CC',
|
|
436
|
+
ECS_CLUSTER: '#FF9900', EKS_CLUSTER: '#FF9900',
|
|
437
|
+
SECURITY_FINDING: '#EF4444', COMPLIANCE_FRAMEWORK: '#14B8A6',
|
|
438
|
+
};
|
|
439
|
+
|
|
440
|
+
const typeRadius = {
|
|
441
|
+
account: 22, region: 18, vpc: 16, vnet: 16, subnet: 14, global: 18,
|
|
442
|
+
};
|
|
443
|
+
|
|
444
|
+
let zoomBehavior, svgG;
|
|
445
|
+
|
|
446
|
+
function renderTopology() {
|
|
447
|
+
const container = document.getElementById('topology-container');
|
|
448
|
+
// Remove existing SVG only
|
|
449
|
+
container.querySelectorAll('svg').forEach(s => s.remove());
|
|
450
|
+
const width = container.clientWidth || 1200;
|
|
451
|
+
const height = 600;
|
|
452
|
+
|
|
453
|
+
if (!hierarchyData || !hierarchyData.children || hierarchyData.children.length === 0) {
|
|
454
|
+
// Fallback to force-directed if no hierarchy
|
|
455
|
+
if (graphData.nodes && graphData.nodes.length > 0) {
|
|
456
|
+
renderForceTopology(container, width, height);
|
|
457
|
+
} else {
|
|
458
|
+
const msg = document.createElement('p');
|
|
459
|
+
msg.style.cssText = 'padding:40px;text-align:center;color:var(--text-muted)';
|
|
460
|
+
msg.textContent = 'No topology data available. Run a collection first.';
|
|
461
|
+
container.appendChild(msg);
|
|
462
|
+
}
|
|
463
|
+
return;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
if (currentLayout === 'force') {
|
|
467
|
+
renderForceTopology(container, width, height);
|
|
468
|
+
} else {
|
|
469
|
+
renderTreeTopology(container, width, height);
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
function renderTreeTopology(container, width, height) {
|
|
474
|
+
const svg = d3.select(container).append('svg').attr('width', width).attr('height', height);
|
|
475
|
+
const g = svg.append('g').attr('transform', 'translate(80, 20)');
|
|
476
|
+
svgG = g;
|
|
477
|
+
|
|
478
|
+
zoomBehavior = d3.zoom().scaleExtent([0.1, 4]).on('zoom', (e) => g.attr('transform', e.transform));
|
|
479
|
+
svg.call(zoomBehavior);
|
|
480
|
+
|
|
481
|
+
const root = d3.hierarchy(hierarchyData);
|
|
482
|
+
root.descendants().forEach(d => { d._children = d.children; });
|
|
483
|
+
|
|
484
|
+
const treeLayout = d3.tree().nodeSize([28, 220]);
|
|
485
|
+
treeLayout(root);
|
|
486
|
+
|
|
487
|
+
// Center vertically
|
|
488
|
+
const yExtent = d3.extent(root.descendants(), d => d.x);
|
|
489
|
+
const yOffset = height / 2 - (yExtent[0] + yExtent[1]) / 2;
|
|
490
|
+
g.attr('transform', `translate(80, ${yOffset})`);
|
|
491
|
+
|
|
492
|
+
// Links
|
|
493
|
+
g.selectAll('.link').data(root.links()).join('path')
|
|
494
|
+
.attr('class', 'link')
|
|
495
|
+
.attr('d', d3.linkHorizontal().x(d => d.y).y(d => d.x))
|
|
496
|
+
.attr('fill', 'none')
|
|
497
|
+
.attr('stroke', '#475569')
|
|
498
|
+
.attr('stroke-width', 1.5)
|
|
499
|
+
.attr('stroke-opacity', 0.6);
|
|
500
|
+
|
|
501
|
+
// Nodes
|
|
502
|
+
const node = g.selectAll('.node').data(root.descendants()).join('g')
|
|
503
|
+
.attr('class', 'node')
|
|
504
|
+
.attr('transform', d => `translate(${d.y},${d.x})`)
|
|
505
|
+
.style('cursor', d => d.children || d._children ? 'pointer' : 'default')
|
|
506
|
+
.on('click', (e, d) => {
|
|
507
|
+
if (d.children) { d._children = d.children; d.children = null; }
|
|
508
|
+
else if (d._children) { d.children = d._children; d._children = null; }
|
|
509
|
+
renderTopology();
|
|
510
|
+
});
|
|
511
|
+
|
|
512
|
+
// Node circles
|
|
513
|
+
node.append('circle')
|
|
514
|
+
.attr('r', d => {
|
|
515
|
+
const nodeData = d.data;
|
|
516
|
+
return typeRadius[nodeData.type] || 10;
|
|
517
|
+
})
|
|
518
|
+
.attr('fill', d => typeColors[d.data.type] || '#95A5A6')
|
|
519
|
+
.attr('stroke', d => {
|
|
520
|
+
const nodeData = d.data;
|
|
521
|
+
if (nodeData.findings && nodeData.findings.total > 0) {
|
|
522
|
+
if (nodeData.findings.CRITICAL > 0) return '#EF4444';
|
|
523
|
+
if (nodeData.findings.HIGH > 0) return '#F97316';
|
|
524
|
+
return '#EAB308';
|
|
525
|
+
}
|
|
526
|
+
if (nodeData.internet_exposed) return '#FF9900';
|
|
527
|
+
return 'rgba(255,255,255,0.3)';
|
|
528
|
+
})
|
|
529
|
+
.attr('stroke-width', d => {
|
|
530
|
+
const nodeData = d.data;
|
|
531
|
+
if ((nodeData.findings && nodeData.findings.total > 0) || nodeData.internet_exposed) return 3;
|
|
532
|
+
return 1.5;
|
|
533
|
+
});
|
|
534
|
+
|
|
535
|
+
// Findings badge
|
|
536
|
+
node.filter(d => d.data.findings && d.data.findings.total > 0)
|
|
537
|
+
.append('circle')
|
|
538
|
+
.attr('cx', d => (typeRadius[d.data.type] || 10) - 2)
|
|
539
|
+
.attr('cy', d => -(typeRadius[d.data.type] || 10) + 2)
|
|
540
|
+
.attr('r', 8)
|
|
541
|
+
.attr('fill', d => {
|
|
542
|
+
if (d.data.findings.CRITICAL > 0) return '#EF4444';
|
|
543
|
+
if (d.data.findings.HIGH > 0) return '#F97316';
|
|
544
|
+
return '#EAB308';
|
|
545
|
+
});
|
|
546
|
+
|
|
547
|
+
node.filter(d => d.data.findings && d.data.findings.total > 0)
|
|
548
|
+
.append('text')
|
|
549
|
+
.attr('x', d => (typeRadius[d.data.type] || 10) - 2)
|
|
550
|
+
.attr('y', d => -(typeRadius[d.data.type] || 10) + 6)
|
|
551
|
+
.attr('text-anchor', 'middle')
|
|
552
|
+
.attr('fill', 'white')
|
|
553
|
+
.attr('font-size', '9px')
|
|
554
|
+
.attr('font-weight', '700')
|
|
555
|
+
.text(d => d.data.findings.total);
|
|
556
|
+
|
|
557
|
+
// Collapse indicator
|
|
558
|
+
node.filter(d => d._children && !d.children)
|
|
559
|
+
.append('text')
|
|
560
|
+
.attr('x', 0).attr('y', 4)
|
|
561
|
+
.attr('text-anchor', 'middle')
|
|
562
|
+
.attr('fill', 'white')
|
|
563
|
+
.attr('font-size', '14px')
|
|
564
|
+
.attr('font-weight', '700')
|
|
565
|
+
.text('+');
|
|
566
|
+
|
|
567
|
+
// Labels
|
|
568
|
+
node.append('text')
|
|
569
|
+
.attr('x', d => (d.children || d._children ? -(typeRadius[d.data.type] || 10) - 6 : (typeRadius[d.data.type] || 10) + 6))
|
|
570
|
+
.attr('dy', '0.35em')
|
|
571
|
+
.attr('text-anchor', d => d.children || d._children ? 'end' : 'start')
|
|
572
|
+
.attr('fill', '#CBD5E1')
|
|
573
|
+
.attr('font-size', d => ['account','region','vpc'].includes(d.data.type) ? '13px' : '11px')
|
|
574
|
+
.attr('font-weight', d => ['account','region','vpc'].includes(d.data.type) ? '600' : '400')
|
|
575
|
+
.text(d => {
|
|
576
|
+
const name = d.data.name || d.data.id || '';
|
|
577
|
+
return name.length > 35 ? name.substring(0, 32) + '…' : name;
|
|
578
|
+
});
|
|
579
|
+
|
|
580
|
+
// Type badge for leaf nodes
|
|
581
|
+
node.filter(d => d.data.type && !['account','region','vpc','subnet','global','vnet'].includes(d.data.type))
|
|
582
|
+
.append('text')
|
|
583
|
+
.attr('x', d => (typeRadius[d.data.type] || 10) + 6)
|
|
584
|
+
.attr('dy', '1.8em')
|
|
585
|
+
.attr('fill', '#64748B')
|
|
586
|
+
.attr('font-size', '9px')
|
|
587
|
+
.text(d => d.data.type);
|
|
588
|
+
|
|
589
|
+
// Tooltips
|
|
590
|
+
node.append('title').text(d => {
|
|
591
|
+
let tip = `${d.data.type}: ${d.data.name || d.data.id || ''}`;
|
|
592
|
+
if (d.data.arn) tip += `\nARN: ${d.data.arn}`;
|
|
593
|
+
if (d.data.findings && d.data.findings.total > 0) {
|
|
594
|
+
tip += `\n\nFindings: ${d.data.findings.total}`;
|
|
595
|
+
if (d.data.findings.CRITICAL) tip += `\n Critical: ${d.data.findings.CRITICAL}`;
|
|
596
|
+
if (d.data.findings.HIGH) tip += `\n High: ${d.data.findings.HIGH}`;
|
|
597
|
+
if (d.data.findings.MEDIUM) tip += `\n Medium: ${d.data.findings.MEDIUM}`;
|
|
598
|
+
}
|
|
599
|
+
if (d.data.internet_exposed) tip += '\n\n⚠ INTERNET EXPOSED';
|
|
600
|
+
return tip;
|
|
601
|
+
});
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
function renderForceTopology(container, width, height) {
|
|
605
|
+
const svg = d3.select(container).append('svg').attr('width', width).attr('height', height);
|
|
606
|
+
const g = svg.append('g');
|
|
607
|
+
svgG = g;
|
|
608
|
+
|
|
609
|
+
zoomBehavior = d3.zoom().scaleExtent([0.2, 5]).on('zoom', (e) => g.attr('transform', e.transform));
|
|
610
|
+
svg.call(zoomBehavior);
|
|
611
|
+
|
|
612
|
+
if (!graphData.nodes || graphData.nodes.length === 0) return;
|
|
613
|
+
|
|
614
|
+
const sim = d3.forceSimulation(graphData.nodes)
|
|
615
|
+
.force('link', d3.forceLink(graphData.links).id(d => d.id).distance(100))
|
|
616
|
+
.force('charge', d3.forceManyBody().strength(-200))
|
|
617
|
+
.force('center', d3.forceCenter(width / 2, height / 2))
|
|
618
|
+
.force('collision', d3.forceCollide().radius(30));
|
|
619
|
+
|
|
620
|
+
const link = g.append('g').selectAll('line').data(graphData.links).join('line')
|
|
621
|
+
.attr('stroke', d => {
|
|
622
|
+
if (d.relation === 'FINDING_AFFECTS') {
|
|
623
|
+
const sevColors = {CRITICAL:'#EF4444',HIGH:'#F97316',MEDIUM:'#EAB308',LOW:'#3498DB'};
|
|
624
|
+
return sevColors[d.severity] || '#EF4444';
|
|
625
|
+
}
|
|
626
|
+
if (d.relation === 'COMPLIANCE_GOVERNS') return '#14B8A6';
|
|
627
|
+
return d.cidr === '0.0.0.0/0' ? '#E74C3C' : '#555';
|
|
628
|
+
})
|
|
629
|
+
.attr('stroke-width', d => {
|
|
630
|
+
if (d.relation === 'FINDING_AFFECTS') return 2;
|
|
631
|
+
if (d.relation === 'COMPLIANCE_GOVERNS') return 1.5;
|
|
632
|
+
return d.cidr === '0.0.0.0/0' ? 2 : 1;
|
|
633
|
+
})
|
|
634
|
+
.attr('stroke-dasharray', d => {
|
|
635
|
+
if (d.relation === 'FINDING_AFFECTS' || d.relation === 'COMPLIANCE_GOVERNS') return '6,3';
|
|
636
|
+
return null;
|
|
637
|
+
})
|
|
638
|
+
.attr('stroke-opacity', d => d.relation ? 0.7 : 0.5);
|
|
639
|
+
|
|
640
|
+
const node = g.append('g').selectAll('g').data(graphData.nodes).join('g')
|
|
641
|
+
.call(d3.drag().on('start', dragstarted).on('drag', dragged).on('end', dragended));
|
|
642
|
+
|
|
643
|
+
// Node shape — findings get triangles, compliance gets diamonds, rest get circles
|
|
644
|
+
node.each(function(d) {
|
|
645
|
+
const el = d3.select(this);
|
|
646
|
+
const r = d.is_external ? 8 : 16;
|
|
647
|
+
if (d.type === 'SECURITY_FINDING') {
|
|
648
|
+
// Triangle for findings
|
|
649
|
+
const sevColors = {CRITICAL:'#EF4444',HIGH:'#F97316',MEDIUM:'#EAB308',LOW:'#3498DB',INFO:'#64748B'};
|
|
650
|
+
el.append('polygon')
|
|
651
|
+
.attr('points', `0,${-r} ${r},${r} ${-r},${r}`)
|
|
652
|
+
.attr('fill', sevColors[d.severity] || '#EF4444')
|
|
653
|
+
.attr('stroke', '#fff')
|
|
654
|
+
.attr('stroke-width', 1.5);
|
|
655
|
+
} else if (d.type === 'COMPLIANCE_FRAMEWORK') {
|
|
656
|
+
// Diamond for compliance
|
|
657
|
+
el.append('polygon')
|
|
658
|
+
.attr('points', `0,${-r} ${r},0 0,${r} ${-r},0`)
|
|
659
|
+
.attr('fill', '#14B8A6')
|
|
660
|
+
.attr('stroke', '#fff')
|
|
661
|
+
.attr('stroke-width', 1.5);
|
|
662
|
+
} else {
|
|
663
|
+
el.append('circle').attr('r', r)
|
|
664
|
+
.attr('fill', typeColors[d.type] || '#95A5A6')
|
|
665
|
+
.attr('stroke', d.is_internet_exposed ? '#FF0000' : '#fff')
|
|
666
|
+
.attr('stroke-width', d.is_internet_exposed ? 3 : 1.5);
|
|
667
|
+
}
|
|
668
|
+
});
|
|
669
|
+
|
|
670
|
+
node.append('text').text(d => d.name ? d.name.substring(0, 15) : d.id.substring(0, 10))
|
|
671
|
+
.attr('dy', 28).attr('text-anchor', 'middle')
|
|
672
|
+
.attr('fill', '#CBD5E1').attr('font-size', '10px');
|
|
673
|
+
|
|
674
|
+
node.append('title').text(d => `${d.type}: ${d.name}\nRegion: ${d.region}\nARN: ${d.arn || 'N/A'}`);
|
|
675
|
+
|
|
676
|
+
sim.on('tick', () => {
|
|
677
|
+
link.attr('x1', d => d.source.x).attr('y1', d => d.source.y)
|
|
678
|
+
.attr('x2', d => d.target.x).attr('y2', d => d.target.y);
|
|
679
|
+
node.attr('transform', d => `translate(${d.x},${d.y})`);
|
|
680
|
+
});
|
|
681
|
+
|
|
682
|
+
function dragstarted(e, d) { if (!e.active) sim.alphaTarget(0.3).restart(); d.fx = d.x; d.fy = d.y; }
|
|
683
|
+
function dragged(e, d) { d.fx = e.x; d.fy = e.y; }
|
|
684
|
+
function dragended(e, d) { if (!e.active) sim.alphaTarget(0); d.fx = null; d.fy = null; }
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
function toggleLayout() {
|
|
688
|
+
currentLayout = currentLayout === 'tree' ? 'force' : 'tree';
|
|
689
|
+
renderTopology();
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
function resetZoom() {
|
|
693
|
+
const svg = d3.select('#topology-container svg');
|
|
694
|
+
if (svg.node() && zoomBehavior) {
|
|
695
|
+
svg.transition().duration(500).call(zoomBehavior.transform, d3.zoomIdentity);
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
function expandAll() {
|
|
700
|
+
function expand(d) { if (d._children) { d.children = d._children; d._children = null; } if (d.children) d.children.forEach(expand); }
|
|
701
|
+
if (hierarchyData) { const root = d3.hierarchy(hierarchyData); expand(root); }
|
|
702
|
+
renderTopology();
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
function collapseAll() {
|
|
706
|
+
// Re-render with collapsed tree (only top 2 levels open)
|
|
707
|
+
renderTopology();
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
// ── Chart.js Charts ──
|
|
711
|
+
function renderCharts() {
|
|
712
|
+
// Severity Donut
|
|
713
|
+
new Chart(document.getElementById('chart-severity'), {
|
|
714
|
+
type: 'doughnut',
|
|
715
|
+
data: {
|
|
716
|
+
labels: Object.keys(severityCounts),
|
|
717
|
+
datasets: [{
|
|
718
|
+
data: Object.values(severityCounts),
|
|
719
|
+
backgroundColor: ['#EF4444', '#F97316', '#EAB308', '#3498DB', '#64748B'],
|
|
720
|
+
borderWidth: 0, hoverOffset: 8,
|
|
721
|
+
}]
|
|
722
|
+
},
|
|
723
|
+
options: {
|
|
724
|
+
responsive: true, plugins: { legend: { position: 'bottom', labels: { color: '#CBD5E1' } } },
|
|
725
|
+
cutout: '65%',
|
|
726
|
+
}
|
|
727
|
+
});
|
|
728
|
+
|
|
729
|
+
// Resource Types Bar
|
|
730
|
+
new Chart(document.getElementById('chart-resources'), {
|
|
731
|
+
type: 'bar',
|
|
732
|
+
data: {
|
|
733
|
+
labels: Object.keys(resourceTypes),
|
|
734
|
+
datasets: [{
|
|
735
|
+
data: Object.values(resourceTypes),
|
|
736
|
+
backgroundColor: '#6366F1', borderRadius: 6,
|
|
737
|
+
}]
|
|
738
|
+
},
|
|
739
|
+
options: {
|
|
740
|
+
responsive: true, indexAxis: 'y',
|
|
741
|
+
plugins: { legend: { display: false } },
|
|
742
|
+
scales: {
|
|
743
|
+
x: { ticks: { color: '#94A3B8' }, grid: { color: '#1E293B' } },
|
|
744
|
+
y: { ticks: { color: '#CBD5E1' }, grid: { display: false } },
|
|
745
|
+
},
|
|
746
|
+
}
|
|
747
|
+
});
|
|
748
|
+
|
|
749
|
+
// Sources Donut
|
|
750
|
+
new Chart(document.getElementById('chart-sources'), {
|
|
751
|
+
type: 'doughnut',
|
|
752
|
+
data: {
|
|
753
|
+
labels: Object.keys(sourceTools),
|
|
754
|
+
datasets: [{
|
|
755
|
+
data: Object.values(sourceTools),
|
|
756
|
+
backgroundColor: ['#6366F1', '#8B5CF6', '#EC4899', '#14B8A6', '#F97316', '#EAB308'],
|
|
757
|
+
borderWidth: 0,
|
|
758
|
+
}]
|
|
759
|
+
},
|
|
760
|
+
options: {
|
|
761
|
+
responsive: true, plugins: { legend: { position: 'bottom', labels: { color: '#CBD5E1' } } },
|
|
762
|
+
cutout: '65%',
|
|
763
|
+
}
|
|
764
|
+
});
|
|
765
|
+
|
|
766
|
+
// Compliance
|
|
767
|
+
const fws = Object.keys(complianceSummary);
|
|
768
|
+
const passData = fws.map(fw => complianceSummary[fw]?.pass || 0);
|
|
769
|
+
const failData = fws.map(fw => complianceSummary[fw]?.fail || 0);
|
|
770
|
+
new Chart(document.getElementById('chart-compliance'), {
|
|
771
|
+
type: 'bar',
|
|
772
|
+
data: {
|
|
773
|
+
labels: fws,
|
|
774
|
+
datasets: [
|
|
775
|
+
{ label: 'Pass', data: passData, backgroundColor: '#22C55E', borderRadius: 4 },
|
|
776
|
+
{ label: 'Fail', data: failData, backgroundColor: '#EF4444', borderRadius: 4 },
|
|
777
|
+
]
|
|
778
|
+
},
|
|
779
|
+
options: {
|
|
780
|
+
responsive: true,
|
|
781
|
+
plugins: { legend: { labels: { color: '#CBD5E1' } } },
|
|
782
|
+
scales: {
|
|
783
|
+
x: { ticks: { color: '#CBD5E1' }, grid: { display: false }, stacked: true },
|
|
784
|
+
y: { ticks: { color: '#94A3B8' }, grid: { color: '#1E293B' }, stacked: true },
|
|
785
|
+
},
|
|
786
|
+
}
|
|
787
|
+
});
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
// ── Compliance Grid ──
|
|
791
|
+
function renderCompliance() {
|
|
792
|
+
const grid = document.getElementById('compliance-grid');
|
|
793
|
+
grid.innerHTML = Object.entries(complianceSummary).map(([fw, data]) => {
|
|
794
|
+
const total = (data.pass || 0) + (data.fail || 0);
|
|
795
|
+
const pct = total > 0 ? Math.round((data.pass / total) * 100) : 0;
|
|
796
|
+
const barColor = pct >= 80 ? 'var(--success)' : pct >= 50 ? 'var(--medium)' : 'var(--critical)';
|
|
797
|
+
return `
|
|
798
|
+
<div class="compliance-card">
|
|
799
|
+
<h4>${fw}</h4>
|
|
800
|
+
<div style="display:flex;justify-content:space-between;color:var(--text-muted);font-size:13px">
|
|
801
|
+
<span>Pass: ${data.pass || 0}</span><span>Fail: ${data.fail || 0}</span><span>${pct}%</span>
|
|
802
|
+
</div>
|
|
803
|
+
<div class="compliance-bar">
|
|
804
|
+
<div class="compliance-bar-fill" style="width:${pct}%;background:${barColor}"></div>
|
|
805
|
+
</div>
|
|
806
|
+
</div>
|
|
807
|
+
`;
|
|
808
|
+
}).join('');
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
// ── Export ──
|
|
812
|
+
function exportJSON() {
|
|
813
|
+
const blob = new Blob([JSON.stringify({findings: findingsData, graph: graphData, hierarchy: hierarchyData}, null, 2)], {type: 'application/json'});
|
|
814
|
+
const a = document.createElement('a');
|
|
815
|
+
a.href = URL.createObjectURL(blob);
|
|
816
|
+
a.download = 'findings.json';
|
|
817
|
+
a.click();
|
|
818
|
+
}
|
|
819
|
+
|
|
820
|
+
// ── Init ──
|
|
821
|
+
renderFindings(findingsData);
|
|
822
|
+
renderTopology();
|
|
823
|
+
renderCharts();
|
|
824
|
+
renderCompliance();
|
|
825
|
+
</script>
|
|
826
|
+
|
|
827
|
+
</body>
|
|
828
|
+
</html>
|