Skip to content

Commit 8601695

Browse files
committed
Made stats graphs clickable, thanks D for the idea
1 parent 89b5b1d commit 8601695

4 files changed

Lines changed: 72 additions & 4 deletions

File tree

docs/js/app.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,27 @@ function showListView() {
336336
if (detailView) detailView.style.display = 'none';
337337
if (nav) nav.style.display = 'block';
338338

339+
// Check for URL parameters and apply filters
340+
const urlParams = new URLSearchParams(window.location.search);
341+
const serviceParam = urlParams.get('service');
342+
const categoryParam = urlParams.get('category');
343+
const detectionParam = urlParams.get('detection');
344+
345+
if (serviceParam) {
346+
serviceFilter.value = serviceParam;
347+
}
348+
if (categoryParam) {
349+
categoryFilter.value = categoryParam;
350+
}
351+
if (detectionParam) {
352+
detectionFilter.value = detectionParam;
353+
}
354+
355+
// Apply filters if parameters were set
356+
if (serviceParam || categoryParam || detectionParam) {
357+
applyFilters();
358+
}
359+
339360
// Update page title
340361
document.title = 'pathfinding.cloud - AWS IAM Privilege Escalation Paths';
341362

@@ -527,6 +548,9 @@ function applyFilters() {
527548
if (selectedDetection === 'none') {
528549
// Show paths with no detection tools
529550
matchesDetection = !path.detectionTools || Object.keys(path.detectionTools).length === 0;
551+
} else if (selectedDetection === 'any') {
552+
// Show paths with at least one detection tool
553+
matchesDetection = path.detectionTools && Object.keys(path.detectionTools).length > 0;
530554
} else {
531555
// Show paths that have the selected detection tool
532556
matchesDetection = path.detectionTools && path.detectionTools[selectedDetection];

docs/paths/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@
259259
<label>OSS Detection:</label>
260260
<select id="detection-filter">
261261
<option value="">All</option>
262+
<option value="any">Any Detection Tool</option>
262263
<option value="pmapper">PMapper</option>
263264
<option value="cloudsplaining">Cloudsplaining</option>
264265
<option value="pacu">Pacu</option>

docs/paths/stats/index.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,14 @@
199199
height: 600px;
200200
}
201201

202+
/* Make clickable charts have pointer cursor */
203+
#service-chart-treemap,
204+
#category-chart,
205+
#detection-coverage-ring,
206+
#detection-tools-chart {
207+
cursor: pointer;
208+
}
209+
202210
.summary-stats {
203211
display: grid;
204212
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));

docs/paths/stats/stats.js

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,16 @@ function createServiceTreemap() {
695695
options: {
696696
responsive: true,
697697
maintainAspectRatio: false,
698+
onClick: (event, elements) => {
699+
if (elements.length > 0) {
700+
const element = elements[0];
701+
const service = element.element.$context.raw._data?.service;
702+
if (service) {
703+
// Navigate to paths page with service filter
704+
window.location.href = `/paths/?service=${service.toLowerCase()}`;
705+
}
706+
}
707+
},
698708
plugins: {
699709
legend: { display: false },
700710
tooltip: {
@@ -704,7 +714,7 @@ function createServiceTreemap() {
704714
},
705715
label: function(context) {
706716
const count = context.raw._data?.count || 0;
707-
return `${count} paths`;
717+
return `${count} paths (Click to view paths)`;
708718
}
709719
}
710720
}
@@ -760,6 +770,16 @@ function createCategoryChart() {
760770
options: {
761771
responsive: true,
762772
maintainAspectRatio: false,
773+
onClick: (event, elements) => {
774+
if (elements.length > 0) {
775+
const index = elements[0].index;
776+
const categoryKey = Object.keys(categoryCounts)[index];
777+
if (categoryKey) {
778+
// Navigate to paths page with category filter
779+
window.location.href = `/paths/?category=${categoryKey}`;
780+
}
781+
}
782+
},
763783
plugins: {
764784
legend: {
765785
display: false
@@ -770,7 +790,7 @@ function createCategoryChart() {
770790
const label = context.label || '';
771791
const value = context.parsed;
772792
const percentage = Math.round((value / allPaths.length) * 100);
773-
return `${label}: ${value} paths (${percentage}%)`;
793+
return `${label}: ${value} paths (${percentage}%) - Click to view paths`;
774794
}
775795
}
776796
}
@@ -856,6 +876,14 @@ function createDetectionCoverageRing() {
856876
options: {
857877
responsive: true,
858878
maintainAspectRatio: false,
879+
onClick: (event, elements) => {
880+
if (elements.length > 0) {
881+
const index = elements[0].index;
882+
// 0 = With Detection, 1 = Without Detection
883+
const detectionParam = index === 0 ? 'any' : 'none';
884+
window.location.href = `/paths/?detection=${detectionParam}`;
885+
}
886+
},
859887
plugins: {
860888
legend: {
861889
display: false
@@ -866,7 +894,7 @@ function createDetectionCoverageRing() {
866894
const label = context.label || '';
867895
const value = context.parsed;
868896
const percentage = Math.round((value / allPaths.length) * 100);
869-
return `${label}: ${value} paths (${percentage}%)`;
897+
return `${label}: ${value} paths (${percentage}%) - Click to view paths`;
870898
}
871899
}
872900
}
@@ -968,6 +996,13 @@ function createDetectionToolsChart() {
968996
indexAxis: 'y',
969997
responsive: true,
970998
maintainAspectRatio: false,
999+
onClick: (event, elements) => {
1000+
if (elements.length > 0) {
1001+
const index = elements[0].index;
1002+
const toolName = sortedTools[index][0]; // Get original tool name
1003+
window.location.href = `/paths/?detection=${toolName}`;
1004+
}
1005+
},
9711006
plugins: {
9721007
legend: {
9731008
display: false
@@ -976,7 +1011,7 @@ function createDetectionToolsChart() {
9761011
callbacks: {
9771012
label: function(context) {
9781013
const percentage = Math.round((context.parsed.x / allPaths.length) * 100);
979-
return `${context.parsed.x} paths (${percentage}%)`;
1014+
return `${context.parsed.x} paths (${percentage}%) - Click to view paths`;
9801015
}
9811016
}
9821017
},

0 commit comments

Comments
 (0)