-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
381 lines (376 loc) · 24.5 KB
/
Copy pathindex.html
File metadata and controls
381 lines (376 loc) · 24.5 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>PathFinder — Azure Identity Attack Path Visualizer</title>
<style>
* { margin:0; padding:0; box-sizing:border-box; }
body { font-family:'Segoe UI',system-ui,-apple-system,sans-serif; background:#0a0e1a; color:#e8eef7; min-height:100vh; }
header { padding:14px 22px 12px; border-bottom:1px solid rgba(77,184,255,0.12); }
header .row { display:flex; align-items:center; gap:12px; flex-wrap:wrap; }
header .title { font-size:17px; font-weight:600; }
header .title span { color:#4db8ff; }
header .badge { font-size:10px; padding:3px 9px; border-radius:12px; background:rgba(77,184,255,0.15); border:1px solid rgba(77,184,255,0.4); color:#9ad4ff; }
header #infoBtn { margin-left:auto; cursor:pointer; font-size:11px; padding:5px 12px; border-radius:14px; background:rgba(77,184,255,0.1); border:1px solid rgba(77,184,255,0.35); color:#9ad4ff; }
header .info-wrap { position:relative; margin-left:auto; }
header #infoBtn { margin-left:0; }
#infoTip { position:absolute; top:130%; right:0; z-index:120; width:340px; padding:14px 16px; border-radius:10px; background:#0d1728; border:1px solid rgba(77,184,255,0.35); box-shadow:0 12px 34px rgba(0,0,0,0.5); font-size:12.5px; line-height:1.55; color:#c4d3e6; display:none; }
header .info-wrap:hover #infoTip { display:block; }
#infoTip .sim { color:#ffd27a; font-weight:700; }
#infoTip b { color:#9ad4ff; }
#infoTip .rw { margin-top:8px; padding-top:8px; border-top:1px solid rgba(77,184,255,0.15); }
@media (max-width:768px){ #infoTip { width:260px; font-size:11.5px; } }
header .tagline { font-size:12px; color:#7089a8; margin-top:6px; }
.ctrlbar { display:flex; align-items:flex-end; gap:14px; padding:14px 22px; flex-wrap:wrap; background:rgba(13,19,35,0.6); border-bottom:1px solid rgba(77,184,255,0.1); }
.ctrlbar .field { display:flex; flex-direction:column; gap:4px; }
.ctrlbar label { font-size:11px; color:#8fa5c0; text-transform:uppercase; letter-spacing:0.5px; }
.ctrlbar select { padding:9px 12px; border-radius:7px; background:#0d1526; color:#e8eef7; border:1px solid rgba(77,184,255,0.3); font-size:14px; min-width:210px; }
.ctrlbar button { padding:10px 20px; background:linear-gradient(135deg,#0078d4,#0a5ca8); color:#fff; border:none; border-radius:7px; font-size:14px; font-weight:600; cursor:pointer; }
.editbar { padding:12px 22px; background:rgba(13,19,35,0.4); border-bottom:1px solid rgba(77,184,255,0.08); }
.editbar .toggle { cursor:pointer; font-size:12px; color:#9ad4ff; user-select:none; display:inline-flex; align-items:center; gap:6px; }
.editbar .body { display:none; margin-top:12px; }
.editbar.open .body { display:block; }
.editbar .addrow { display:flex; align-items:flex-end; gap:10px; flex-wrap:wrap; margin-bottom:12px; }
.editbar .field { display:flex; flex-direction:column; gap:3px; }
.editbar label { font-size:10px; color:#8fa5c0; text-transform:uppercase; letter-spacing:0.5px; }
.editbar select, .editbar input { padding:8px 10px; border-radius:6px; background:#0d1526; color:#e8eef7; border:1px solid rgba(77,184,255,0.3); font-size:13px; }
.editbar select { min-width:170px; }
.editbar input { min-width:150px; }
.editbar .addbtn { padding:9px 16px; background:linear-gradient(135deg,#2e9e6b,#1f7a52); color:#fff; border:none; border-radius:6px; font-size:13px; font-weight:600; cursor:pointer; }
.edgelist { display:flex; flex-direction:column; gap:5px; max-height:150px; overflow-y:auto; }
.edgelist .er { display:flex; align-items:center; gap:8px; font-size:12px; color:#b8cade; background:rgba(255,255,255,0.03); padding:6px 10px; border-radius:6px; }
.edgelist .er .x { margin-left:auto; cursor:pointer; color:#ff8080; font-weight:700; padding:0 4px; }
.editbar .hint { font-size:14px; color:#7089a8; margin-bottom:10px; line-height:1.4; }
@media (max-width:768px){ .editbar select, .editbar input { min-width:0; width:100%; } .editbar .field { flex:1 1 100%; } }
.ctrlbar button.secondary { background:rgba(77,184,255,0.12); border:1px solid rgba(77,184,255,0.3); }
.ctrlbar .arrow { font-size:20px; color:#4db8ff; padding-bottom:8px; }
#verdict { display:none; margin:14px 22px 0; padding:12px 16px; border-radius:10px; font-size:14px; line-height:1.5; }
#verdict.show { display:block; }
#verdict.danger { background:rgba(255,60,60,0.12); border:1px solid rgba(255,80,80,0.4); color:#ffc4c4; }
#verdict.safe { background:rgba(95,217,138,0.1); border:1px solid rgba(95,217,138,0.4); color:#bff0d0; }
#verdict b { color:#fff; }
.stage { margin:14px 22px 22px; background:radial-gradient(circle at 50% 25%, #0f1830, #0a0e1a); border:1px solid rgba(77,184,255,0.15); border-radius:12px; padding:18px; }
.colheads { display:grid; grid-template-columns:1fr 1fr 1fr; gap:60px; margin-bottom:14px; }
.colhead { font-size:12px; text-transform:uppercase; letter-spacing:1px; color:#7fb3e0; text-align:center; padding:6px; border-bottom:1px solid rgba(77,184,255,0.15); }
#diagram { position:relative; }
svg.edges { position:absolute; inset:0; width:100%; height:100%; pointer-events:none; z-index:1; }
.cols { display:grid; grid-template-columns:1fr 1fr 1fr; gap:60px; position:relative; z-index:2; }
.col { display:flex; flex-direction:column; gap:18px; justify-content:center; }
.node { background:#111a2e; border:1.5px solid var(--c); border-radius:10px; padding:12px 14px; display:flex; align-items:center; gap:12px; box-shadow:0 2px 10px rgba(0,0,0,0.3); transition:all 0.25s; }
.node .ico { font-size:24px; width:32px; text-align:center; }
.node .nm { font-size:14px; font-weight:600; color:#eaf2ff; line-height:1.2; }
.node .ty { font-size:10px; color:#8fa5c0; text-transform:uppercase; letter-spacing:0.5px; margin-top:2px; }
.node .sens { font-size:9px; color:#ffb060; margin-top:2px; }
.node.attack { border-color:#ff5555; background:#2a1420; box-shadow:0 0 20px rgba(255,85,85,0.55); transform:scale(1.05); }
.node.attack .nm { color:#ffd0d0; }
.node.dim { opacity:0.3; }
#analysis { display:none; margin:0 22px 22px; background:rgba(12,18,34,0.95); border:1px solid rgba(77,184,255,0.25); border-radius:12px; padding:20px; }
#analysis.open { display:block; }
#analysis .abody { display:block; }
.a-top { display:flex; align-items:center; gap:14px; flex-wrap:wrap; margin-bottom:16px; }
.a-summary { font-size:14px; color:#a8bdd6; }
.steps { display:flex; align-items:stretch; gap:0; flex-wrap:wrap; margin-bottom:18px; }
.step { flex:1 1 0; min-width:165px; background:#111a2e; border:1px solid rgba(255,85,85,0.35); border-radius:9px; padding:11px 13px; position:relative; margin-right:22px; margin-bottom:12px; }
.step:last-child { margin-right:0; }
.step::after { content:"→"; position:absolute; right:-17px; top:50%; transform:translateY(-50%); color:#ff6b6b; font-size:16px; font-weight:700; }
.step:last-child::after { display:none; }
.step .snum { font-size:11px; text-transform:uppercase; letter-spacing:0.6px; color:#ff8080; font-weight:700; margin-bottom:5px; }
.step .snode { font-size:15px; color:#eaf2ff; font-weight:600; line-height:1.25; }
.step .svia { font-size:12px; color:#8fa5c0; margin-top:4px; }
.lesson-band { padding:16px 18px; border-radius:10px; background:rgba(77,184,255,0.08); border:1px solid rgba(77,184,255,0.22); font-size:14.5px; line-height:1.6; color:#c4d8ef; }
.lesson-band b { color:#9ad4ff; }
@media (max-width:768px){ .step { flex:1 1 100%; margin-right:0; } .step::after { content:"↓"; right:50%; top:auto; bottom:-16px; transform:translateX(50%); } }
@media (max-width:768px){ #analysis .abody { grid-template-columns:1fr; } #analysis { margin:0 12px 16px; } }
#analysis .close { float:right; cursor:pointer; color:#8fa5c0; font-size:18px; }
#analysis h3 { font-size:14px; text-transform:uppercase; letter-spacing:1px; color:#7fb3e0; margin-bottom:14px; }
.risk { display:inline-block; padding:5px 12px; border-radius:12px; font-size:13px; font-weight:600; margin-bottom:12px; }
.risk.critical { background:rgba(255,60,60,0.2); color:#ff8080; border:1px solid rgba(255,60,60,0.4); }
.risk.high { background:rgba(255,140,0,0.2); color:#ffb060; border:1px solid rgba(255,140,0,0.4); }
.hop { padding:10px; margin-bottom:8px; border-radius:6px; background:rgba(255,80,80,0.08); border-left:3px solid #ff5555; font-size:12px; line-height:1.5; }
.hop .num { color:#ff8080; font-weight:700; margin-right:6px; }
.hop .node2 { color:#9ad4ff; font-weight:600; }
.lesson { margin-top:12px; padding:12px; border-radius:8px; background:rgba(77,184,255,0.08); border:1px solid rgba(77,184,255,0.2); font-size:12px; line-height:1.55; color:#c4d8ef; }
.lesson b { color:#9ad4ff; }
#overlay { position:fixed; inset:0; z-index:100; background:rgba(6,9,18,0.92); backdrop-filter:blur(4px); display:flex; align-items:flex-start; justify-content:center; overflow-y:auto; padding:20px; }
#overlay .card { max-width:620px; margin:auto; padding:28px; border-radius:16px; background:linear-gradient(160deg,#121a30,#0d1424); border:1px solid rgba(77,184,255,0.3); }
#overlay .tag { font-size:11px; color:#7fb3e0; text-transform:uppercase; letter-spacing:1.5px; margin-bottom:8px; }
#overlay h1 { font-size:24px; color:#fff; margin-bottom:16px; }
#overlay h1 span { color:#4db8ff; }
#overlay p { font-size:14px; line-height:1.65; color:#c4d3e6; margin-bottom:12px; }
#overlay .stat { color:#4db8ff; font-weight:700; }
#overlay .highlight { color:#ff8080; font-weight:600; }
#overlay ul { margin:0 0 16px 18px; }
#overlay li { font-size:13.5px; line-height:1.7; color:#b8c8de; }
#overlay button { padding:12px 26px; background:linear-gradient(135deg,#0078d4,#0a5ca8); color:#fff; border:none; border-radius:8px; font-size:14px; font-weight:600; cursor:pointer; }
#overlay .footnote { font-size:11px; color:#6b7f99; margin-top:14px; }
@media (max-width:768px){
.ctrlbar { gap:10px; }
.ctrlbar .field { flex:1 1 100%; }
.ctrlbar select { width:100%; min-width:0; }
.ctrlbar button { flex:1; }
.ctrlbar .arrow { display:none; }
.colheads, .cols { gap:10px; }
.colheads { font-size:9px; }
.node { padding:8px; gap:6px; flex-direction:column; text-align:center; }
.node .ico { font-size:20px; width:auto; }
.node .nm { font-size:10px; }
.node .ty { font-size:8px; }
.node .sens { font-size:8px; }
#verdict { font-size:12px; margin:12px; }
.stage { margin:12px; padding:12px; }
}
</style>
</head>
<body>
<header>
<div class="row">
<div class="title">Path<span>Finder</span> — Azure Identity Attack Path Visualizer</div>
<div class="badge">MODELED ENVIRONMENT</div>
<div class="info-wrap"><div id="infoBtn">ⓘ What am I looking at?</div><div id="infoTip"><span class="sim">This is a simulation.</span> It runs on a sample modeled environment with example identities and resources — not connected to any real Azure tenant, and using no live data.<div class="rw"><b>Why it matters:</b> what's real is the engine. The same graph path-finding logic shown here is how attack-path analysis works in production — running continuously against live identity data to surface exposure the moment a risky permission is created. Click for the full explanation.</div></div></div>
</div>
<div class="tagline">See how ordinary permissions chain into a breach path an attacker can walk to your sensitive data.</div>
</header>
<div class="ctrlbar">
<div class="field">
<label>Compromised entry point</label>
<select id="startSel"></select>
</div>
<div class="arrow">→</div>
<div class="field">
<label>Sensitive target</label>
<select id="targetSel"></select>
</div>
<button id="findBtn">⚡ Find Attack Path</button>
<button id="resetBtn" class="secondary">Reset</button>
<button id="editBtnMain" class="secondary">✏️ Edit Permissions</button>
</div>
<div class="editbar" id="editbar">
<div class="toggle" id="editToggle" style="font-size:14px;font-weight:600;color:#9ad4ff;">Edit Permissions</div>
<div class="body">
<div class="hint">This is the core lesson: individually-harmless permissions chain into breaches. Add one and re-run to see a safe target become reachable — or remove one to break an attack path.</div>
<div class="addrow">
<div class="field"><label>From (source)</label><select id="eSource"></select></div>
<div class="field"><label>To (target)</label><select id="eTarget"></select></div>
<div class="field"><label>Label</label><input id="eLabel" value="grants access" /></div>
<button class="addbtn" id="eAdd">+ Add Permission</button>
</div>
<div class="edgelist" id="edgeList"></div>
</div>
</div>
<div id="verdict"></div>
<div class="stage">
<div class="colheads">
<div class="colhead">Identities</div>
<div class="colhead">Roles / Permissions</div>
<div class="colhead">Resources</div>
</div>
<div id="diagram">
<svg class="edges" id="edges"></svg>
<div class="cols">
<div class="col" id="col-identity"></div>
<div class="col" id="col-role"></div>
<div class="col" id="col-resource"></div>
</div>
</div>
</div>
<div id="analysis">
<span class="close" id="closeAnalysis">✕</span>
<h3>Attack Path Analysis</h3>
<div class="abody"><div id="analysisBody"></div></div>
</div>
<div id="overlay">
<div class="card">
<div class="tag">Cloud Identity Security</div>
<h1>Path<span>Finder</span></h1>
<p><span class="highlight">Over 80% of cloud breaches</span> don't come from exotic zero-day exploits. They come from ordinary, individually-harmless permissions that <b>chain together</b> into a path an attacker can walk to your most sensitive data.</p>
<p>A stale access key. A "temporary" role. A service principal with too much scope. One at a time, each looks fine. <span class="stat">Combined, they're a breach.</span></p>
<p>Most tools hand you a list of findings. PathFinder <b>shows the actual path</b> — which combination of permissions lets an attacker move from a compromised identity to your crown-jewel data.</p>
<ul>
<li>Pick a <b>compromised identity</b> and a <b>sensitive target</b></li>
<li>Watch the breach path light up, hop by hop</li>
<li>See why each step works — and that none of it needed a vulnerability</li>
</ul>
<button id="startBtn">Explore the Environment →</button>
<div class="footnote">Runs a real graph path-finding algorithm on a modeled Azure environment. No live tenant data.</div>
</div>
</div>
<script>
const MODEL = {
nodes: [
{ id:'u-dev', name:'Dev User (jsmith)', type:'identity', icon:'\ud83d\udc64' },
{ id:'sp-cicd', name:'CI/CD Service Principal', type:'identity', icon:'\u2699\ufe0f' },
{ id:'mi-web', name:'Web App Managed Identity', type:'identity', icon:'\ud83c\udf10' },
{ id:'r-contrib-rg', name:'Contributor / app-rg', type:'role', icon:'\ud83d\udd11' },
{ id:'r-kv-reader', name:'Key Vault Secrets User', type:'role', icon:'\ud83d\udd11' },
{ id:'r-storage-owner', name:'Storage Blob Owner', type:'role', icon:'\ud83d\udd11' },
{ id:'res-appvm', name:'App VM', type:'resource', sensitivity:1, icon:'\ud83d\udda5\ufe0f' },
{ id:'res-kv', name:'Key Vault (prod-kv)', type:'resource', sensitivity:3, icon:'\ud83d\udd10' },
{ id:'res-storage', name:'Storage: customer-data', type:'resource', sensitivity:5, icon:'\ud83d\uddc4\ufe0f' },
{ id:'res-sqldb', name:'SQL DB: billing', type:'resource', sensitivity:5, icon:'\ud83d\uddc3\ufe0f' }
],
edges: [
{ source:'u-dev', target:'r-contrib-rg', label:'assigned' },
{ source:'r-contrib-rg', target:'res-appvm', label:'controls' },
{ source:'r-contrib-rg', target:'r-kv-reader', label:'can grant self' },
{ source:'r-kv-reader', target:'res-kv', label:'reads secrets' },
{ source:'res-kv', target:'r-storage-owner', label:'secret grants' },
{ source:'r-storage-owner', target:'res-storage', label:'full access' },
{ source:'sp-cicd', target:'r-contrib-rg', label:'assigned' },
{ source:'mi-web', target:'r-kv-reader', label:'assigned' },
{ source:'r-storage-owner', target:'res-sqldb', label:'linked access' }
]
};
const C = { identity:'#4db8ff', role:'#b388ff', resource:'#5fd98a' };
function buildAdjacency(m){const a={};m.nodes.forEach(n=>a[n.id]=[]);m.edges.forEach(e=>a[e.source].push({to:e.target,label:e.label}));return a;}
function findAllPaths(adj,s,t,md){md=md||8;const r=[];function dfs(c,p,v){if(p.length>md)return;if(c===t){r.push(p.slice());return;}for(const e of(adj[c]||[])){if(!v.has(e.to)){v.add(e.to);p.push({node:e.to,viaLabel:e.label});dfs(e.to,p,v);p.pop();v.delete(e.to);}}}dfs(s,[{node:s,viaLabel:null}],new Set([s]));r.sort((a,b)=>a.length-b.length);return r;}
function score(p){const t=MODEL.nodes.find(n=>n.id===p[p.length-1].node);const sn=t.sensitivity||1;const h=p.length-1;return(sn>=4&&h<=5)?'critical':'high';}
const nm = id => (MODEL.nodes.find(n=>n.id===id)||{}).name||id;
const nodeEls = {};
function renderNodes(){
MODEL.nodes.forEach(n=>{
const el=document.createElement('div');
el.className='node'; el.style.setProperty('--c',C[n.type]); el.id='node-'+n.id;
let sens = n.sensitivity ? '<div class="sens">Sensitivity '+n.sensitivity+'/5</div>' : '';
el.innerHTML='<div class="ico">'+n.icon+'</div><div class="meta"><div class="nm">'+n.name+'</div><div class="ty">'+n.type+'</div>'+sens+'</div>';
document.getElementById('col-'+n.type).appendChild(el);
nodeEls[n.id]=el;
});
}
renderNodes();
const svg = document.getElementById('edges');
function drawEdges(activePairs){
const diagram=document.getElementById('diagram');
const dr=diagram.getBoundingClientRect();
svg.setAttribute('width',dr.width); svg.setAttribute('height',dr.height);
svg.innerHTML='';
MODEL.edges.forEach(e=>{
const a=nodeEls[e.source].getBoundingClientRect();
const b=nodeEls[e.target].getBoundingClientRect();
const x1=a.right-dr.left, y1=a.top+a.height/2-dr.top;
const x2=b.left-dr.left, y2=b.top+b.height/2-dr.top;
const active = activePairs && activePairs.has(e.source+'>'+e.target);
const line=document.createElementNS('http://www.w3.org/2000/svg','path');
const mx=(x1+x2)/2;
line.setAttribute('d','M '+x1+' '+y1+' C '+mx+' '+y1+' '+mx+' '+y2+' '+x2+' '+y2);
line.setAttribute('fill','none');
line.setAttribute('stroke', active?'#ff5555':'rgba(120,175,225,0.45)');
line.setAttribute('stroke-width', active?'3.5':'1.6');
if(active){ line.setAttribute('filter','drop-shadow(0 0 4px rgba(255,85,85,0.7))'); }
svg.appendChild(line);
});
}
let currentActive=null;
function redraw(active){ currentActive=active; drawEdges(active); }
window.addEventListener('resize',()=>drawEdges(currentActive));
function clearHighlight(){
Object.values(nodeEls).forEach(el=>{el.classList.remove('attack');el.classList.remove('dim');});
redraw(null);
}
function highlight(path){
const ids=path.map(p=>p.node);
const pairs=new Set();
for(let i=0;i<ids.length-1;i++) pairs.add(ids[i]+'>'+ids[i+1]);
Object.entries(nodeEls).forEach(([id,el])=>{
if(ids.includes(id)){el.classList.add('attack');el.classList.remove('dim');}
else{el.classList.add('dim');el.classList.remove('attack');}
});
redraw(pairs);
}
function fill(){
const ss=document.getElementById('startSel'), ts=document.getElementById('targetSel');
MODEL.nodes.filter(n=>n.type==='identity').forEach(n=>{const o=document.createElement('option');o.value=n.id;o.textContent=n.name;ss.appendChild(o);});
MODEL.nodes.filter(n=>n.type==='resource').forEach(n=>{const o=document.createElement('option');o.value=n.id;o.textContent=n.name;ts.appendChild(o);});
ss.value='u-dev'; ts.value='res-storage';
}
fill();
// ---- Edge editing ----
function allNodeOptions(sel){
sel.innerHTML='';
MODEL.nodes.forEach(n=>{const o=document.createElement('option');o.value=n.id;o.textContent=n.name;sel.appendChild(o);});
}
function renderEdgeList(){
const list=document.getElementById('edgeList'); list.innerHTML='';
MODEL.edges.forEach((e,i)=>{
const row=document.createElement('div'); row.className='er';
row.innerHTML='<span>'+nm(e.source)+' \u2192 '+nm(e.target)+' <span style="color:#8fa5c0">('+e.label+')</span></span><span class="x" data-i="'+i+'">\u2715</span>';
list.appendChild(row);
});
list.querySelectorAll('.x').forEach(x=>x.addEventListener('click',()=>{
MODEL.edges.splice(parseInt(x.dataset.i),1);
afterEdgeChange();
}));
}
function afterEdgeChange(){
renderEdgeList();
clearHighlight();
drawEdges(null);
const v=document.getElementById('verdict'); v.className='';
document.getElementById('analysis').classList.remove('open');
}
(function initEdit(){
allNodeOptions(document.getElementById('eSource'));
allNodeOptions(document.getElementById('eTarget'));
document.getElementById('eTarget').selectedIndex=1;
renderEdgeList();
document.getElementById('editToggle').addEventListener('click',()=>{
document.getElementById('editbar').classList.toggle('open');
});
var _editMainBtn=document.getElementById('editBtnMain');
if(_editMainBtn){ _editMainBtn.addEventListener('click',function(){ var eb=document.getElementById('editbar'); eb.classList.add('open'); eb.scrollIntoView({behavior:'smooth',block:'nearest'}); }); }
document.getElementById('eAdd').addEventListener('click',()=>{
const src=document.getElementById('eSource').value;
const tgt=document.getElementById('eTarget').value;
const lbl=document.getElementById('eLabel').value.trim()||'grants access';
if(src===tgt) return;
if(MODEL.edges.some(e=>e.source===src&&e.target===tgt)) return;
MODEL.edges.push({source:src,target:tgt,label:lbl});
afterEdgeChange();
});
})();
const verdict=document.getElementById('verdict');
document.getElementById('findBtn').addEventListener('click',()=>{
const s=document.getElementById('startSel').value, t=document.getElementById('targetSel').value;
const paths=findAllPaths(buildAdjacency(MODEL),s,t);
const body=document.getElementById('analysisBody');
if(paths.length===0){
clearHighlight();
verdict.className='show safe';
verdict.innerHTML='\u2705 <b>'+nm(s)+'</b> cannot reach <b>'+nm(t)+'</b>. This identity is properly contained \u2014 no attack path exists.';
body.innerHTML='<div style="font-size:13px;color:#5fd98a;line-height:1.5;">No attack path found. In a real environment, this is the outcome you want.</div>';
document.getElementById('analysis').classList.add('open');
return;
}
const best=paths[0];
clearHighlight();
let step=0;
const ids=best.map(p=>p.node);
const timer=setInterval(()=>{
if(step>=ids.length){clearInterval(timer);return;}
highlight(best.slice(0,step+1));
step++;
},420);
const r=score(best);
verdict.className='show danger';
verdict.innerHTML='\u26a0\ufe0f A compromised <b>'+nm(s)+'</b> can reach <b>'+nm(t)+'</b> in <b>'+(best.length-1)+' steps</b> \u2014 no vulnerability required.';
let html='<div class="a-top"><span class="risk '+r+'">'+r.toUpperCase()+' '+(best.length-1)+'-hop path</span><span class="a-summary">'+paths.length+' path(s) found. Showing the shortest, most dangerous route from entry to target.</span></div>';
html+='<div class="steps">';
for(let i=0;i<best.length;i++){const st=best[i];if(i===0){html+='<div class="step"><div class="snum">Start - Compromised</div><div class="snode">'+nm(st.node)+'</div></div>';}else{html+='<div class="step"><div class="snum">Step '+i+'</div><div class="snode">'+nm(st.node)+'</div><div class="svia">via: '+st.viaLabel+'</div></div>';}}
html+='</div>';
html+='<div class="lesson-band"><b>Why this matters:</b> Every permission in this chain is a legitimate, common assignment - no misconfiguration, no vulnerability, no exploit. Yet chained together, they let an attacker who compromises <b>'+nm(s)+'</b> reach <b>'+nm(t)+'</b> in '+(best.length-1)+' hops. This is the exposure that findings-list tools miss and attack-path analysis catches.</div>';
body.innerHTML=html;
document.getElementById('analysis').classList.add('open');
});
document.getElementById('resetBtn').addEventListener('click',()=>{
clearHighlight();
verdict.className='';
document.getElementById('analysis').classList.remove('open');
});
document.getElementById('closeAnalysis').addEventListener('click',()=>{document.getElementById('analysis').classList.remove('open');});
document.getElementById('startBtn').addEventListener('click',()=>{document.getElementById('overlay').style.display='none';setTimeout(()=>drawEdges(null),150);setTimeout(()=>drawEdges(null),450);});
document.getElementById('infoBtn').addEventListener('click',()=>{document.getElementById('overlay').style.display='flex';});
window.addEventListener('load',()=>setTimeout(()=>drawEdges(null),200));
setTimeout(()=>drawEdges(null),400);
</script>
</body>
</html>