Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import shutil
from datetime import datetime
from threading import Lock
from flask import Flask, jsonify, render_template, send_from_directory, request
from flask import Flask, jsonify, render_template, send_from_directory, request, redirect
import psutil

# Try to import OpenAI (optional)
Expand Down Expand Up @@ -708,10 +708,15 @@ def index():
# Serve index.html from root directory
return send_from_directory('.', 'index.html')

@app.route('/linux-crypto-subsystem')
def linux_crypto_subsystem_page():
"""SEO-friendly Linux crypto subsystem page."""
return render_template('linux-crypto-subsystem.html')

@app.route('/crypto')
def crypto_page():
"""SEO-friendly crypto subsystem page."""
return render_template('crypto.html')
def crypto_page_legacy():
"""Legacy path redirect to Linux crypto subsystem page."""
return redirect('/linux-crypto-subsystem', code=301)

@app.route('/api/syscalls-realtime')
def syscalls_realtime():
Expand Down
6 changes: 3 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,11 @@ <h2>Linux Kernel Ring 0 Visualization</h2>
<script src="/static/js/ui-chrome.js?v=1"></script>
<script src="/static/js/active-connections.js?v=4"></script>
<script src="/static/js/nginx_files.js?v=2"></script>
<script src="/static/js/right-semicircle-menu.js?v=42"></script>
<script src="/static/js/right-semicircle-menu.js?v=43"></script>
<script src="/static/js/kernel-dna.js?v=23"></script>
<script src="/static/js/network-stack.js?v=6"></script>
<script src="/static/js/devices-belt.js?v=14"></script>
<script src="/static/js/crypto-belt.js?v=16"></script>
<script src="/static/js/crypto-belt.js?v=20"></script>
<script src="/static/js/filesystem-map.js?v=3"></script>
<script src="/static/js/kernel-context-menu.js?v=25"></script>
<!-- 3D visualization script - DISABLED -->
Expand All @@ -121,6 +121,6 @@ <h2>Linux Kernel Ring 0 Visualization</h2>
// console.error('❌ Proc3DVisualization class NOT loaded!');
// }
</script>
<script src="/static/js/main.js?v=167"></script>
<script src="/static/js/main.js?v=168"></script>
</body>
</html>
97 changes: 86 additions & 11 deletions static/js/crypto-belt.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
this.selectedCompetitionAlgorithm = 'AES';
this.algorithmModes = ['AES', 'SHA', 'CHACHA20'];
this.selectedClientFilters = new Set();
this.selectedRequesterFilter = null;
}

init(containerId = 'crypto-belt-container') {
Expand Down Expand Up @@ -272,7 +273,9 @@

btn.onclick = () => {
const path = String(window.location.pathname || '').replace(/\/+$/, '') || '/';
if (path === '/crypto' && window.history && typeof window.history.replaceState === 'function') {
if ((path === '/crypto' || path === '/linux-crypto-subsystem')
&& window.history
&& typeof window.history.replaceState === 'function') {
window.history.replaceState({}, '', '/');
}
if (window.kernelContextMenu) {
Expand Down Expand Up @@ -545,7 +548,7 @@
getCompetitionPayload(meta) {
const selected = String(this.selectedCompetitionAlgorithm || 'AES').toLowerCase();
const groups = meta?.algorithm_competitions || null;
if (groups && groups[selected]) return groups[selected];

Check warning on line 551 in static/js/crypto-belt.js

View workflow job for this annotation

GitHub Actions / security

Generic Object Injection Sink

Check warning on line 551 in static/js/crypto-belt.js

View workflow job for this annotation

GitHub Actions / security

Generic Object Injection Sink
return meta?.algorithm_competition || {
request: this.selectedCompetitionAlgorithm,
implementations: [],
Expand All @@ -557,7 +560,7 @@
getDecisionPipelinePayload(meta) {
const selected = String(this.selectedCompetitionAlgorithm || 'AES').toLowerCase();
const groups = meta?.crypto_decision_pipelines || null;
if (groups && groups[selected]) return groups[selected];

Check warning on line 563 in static/js/crypto-belt.js

View workflow job for this annotation

GitHub Actions / security

Generic Object Injection Sink

Check warning on line 563 in static/js/crypto-belt.js

View workflow job for this annotation

GitHub Actions / security

Generic Object Injection Sink
return meta?.crypto_decision_pipeline || {
request: this.selectedCompetitionAlgorithm,
request_origin: 'user/kernel request',
Expand Down Expand Up @@ -764,19 +767,47 @@
.attr('y', panelY + 56)
.style('font-family', 'Share Tech Mono, monospace')
.style('font-size', '9px')
.style('fill', '#8696ab')
.style('fill', '#708095')
.text('none detected');
} else {
requesters.forEach((req, idx) => {
const reqName = String(req.name || 'unknown');
const reqKind = String(req.kind || 'generic');
const reqScore = Number(req.score || 0);
panel.append('text')
const isActiveRequester = Boolean(
this.selectedRequesterFilter
&& String(this.selectedRequesterFilter.name || '').toLowerCase() === reqName.toLowerCase()
&& String(this.selectedRequesterFilter.kind || '').toLowerCase() === reqKind.toLowerCase()
);
const row = panel.append('g')
.style('cursor', 'pointer')
.on('click', () => {
if (
this.selectedRequesterFilter
&& String(this.selectedRequesterFilter.name || '').toLowerCase() === reqName.toLowerCase()
&& String(this.selectedRequesterFilter.kind || '').toLowerCase() === reqKind.toLowerCase()
) {
this.selectedRequesterFilter = null;
} else {
this.selectedRequesterFilter = { name: reqName, kind: reqKind };
}
this.renderFlowMap(this.lastPayload || this.normalizeTelemetry(this.getFallbackTelemetry()));
});
row.append('rect')
.attr('x', panelX + 10)
.attr('y', panelY + 46 + idx * 14)
.attr('width', panelW - 20)
.attr('height', 13)
.attr('rx', 3)
.style('fill', isActiveRequester ? 'rgba(37, 58, 92, 0.62)' : 'transparent')
.style('stroke', isActiveRequester ? 'rgba(120, 170, 245, 0.72)' : 'transparent')
.style('stroke-width', 0.8);
row.append('text')
.attr('x', panelX + 14)
.attr('y', panelY + 56 + idx * 14)
.style('font-family', 'Share Tech Mono, monospace')
.style('font-size', '9px')
.style('fill', idx === 0 ? '#cce2ff' : '#95a6bc')
.style('fill', isActiveRequester ? '#e1eeff' : (idx === 0 ? '#cce2ff' : '#95a6bc'))
.text(`- ${reqName} [${reqKind}] (${reqScore})`);
});
}
Expand Down Expand Up @@ -1024,6 +1055,36 @@
return false;
}

laneMatchesSelectedRequester(lane) {
const req = this.selectedRequesterFilter;
if (!req) return true;

const reqName = String(req.name || '').toLowerCase();
const reqKind = String(req.kind || '').toLowerCase();
const process = String(lane?.process || '').toLowerCase();
const protocol = String(lane?.protocol || '').toUpperCase();
const algo = String(lane?.algorithm || '').toLowerCase();

const selectedAlgo = String(this.selectedCompetitionAlgorithm || 'AES').toLowerCase();
let algoMatch = true;
if (selectedAlgo === 'aes') {
algoMatch = algo.includes('aes') || protocol === 'TLS';
} else if (selectedAlgo === 'sha') {
algoMatch = algo.includes('sha') || protocol === 'TLS';
} else if (selectedAlgo === 'chacha20') {
algoMatch = algo.includes('chacha') || protocol === 'WIREGUARD' || protocol === 'SSH';
}
if (!algoMatch) return false;

if (reqKind === 'kernel-client') {
return this.laneMatchesClient(reqName, lane);
}
if (reqKind === 'process') {
return process.includes(reqName);
}
return process.includes(reqName) || protocol.toLowerCase().includes(reqName) || algo.includes(reqName);
}

drawNode(group, x, y, label, level, intensity, palette, emphasis) {
const width = Math.min(Math.max(150, String(label).length * 8 + 28), 250);
const height = 34;
Expand Down Expand Up @@ -1064,7 +1125,7 @@
const path = d3.path();
path.moveTo(points[0].x, points[0].y);
for (let i = 1; i < points.length; i += 1) {
path.lineTo(points[i].x, points[i].y);

Check warning on line 1128 in static/js/crypto-belt.js

View workflow job for this annotation

GitHub Actions / security

Generic Object Injection Sink

Check warning on line 1128 in static/js/crypto-belt.js

View workflow job for this annotation

GitHub Actions / security

Generic Object Injection Sink
}

group.append('path')
Expand Down Expand Up @@ -1097,8 +1158,8 @@
let chain = dot.transition().duration(0);
for (let i = 1; i < points.length; i += 1) {
chain = chain.duration(segmentDuration)
.attr('cx', points[i].x)

Check warning on line 1161 in static/js/crypto-belt.js

View workflow job for this annotation

GitHub Actions / security

Generic Object Injection Sink
.attr('cy', points[i].y);

Check warning on line 1162 in static/js/crypto-belt.js

View workflow job for this annotation

GitHub Actions / security

Generic Object Injection Sink
}

chain.on('end', () => {
Expand Down Expand Up @@ -1129,7 +1190,9 @@
this.drawStage1Panels(layer, payload?.meta || {}, width, height);

const sourceLanes = Array.isArray(payload.items) ? payload.items : [];
const lanes = sourceLanes.filter((lane) => this.laneMatchesSelectedClients(lane));
const lanes = sourceLanes.filter(
(lane) => this.laneMatchesSelectedClients(lane) && this.laneMatchesSelectedRequester(lane)
);
const topY = 150;
const protocolY = 250;
const cryptoY = 350;
Expand All @@ -1145,20 +1208,23 @@
const selectedLabel = this.selectedClientFilters.size
? Array.from(this.selectedClientFilters).join(' + ')
: 'ALL';
const requesterLabel = this.selectedRequesterFilter
? ` | requester:${this.selectedRequesterFilter.name}`
: '';
layer.append('text')
.attr('x', width * 0.42)
.attr('y', 320)
.attr('text-anchor', 'middle')
.style('font-family', 'Share Tech Mono, monospace')
.style('font-size', '12px')
.style('fill', '#8fa0b6')
.text(`NO ACTIVE PATHS FOR ${selectedLabel.toUpperCase()}`);
.text(`NO ACTIVE PATHS FOR ${selectedLabel.toUpperCase()}${requesterLabel.toUpperCase()}`);
}

lanes.forEach((lane, idx) => {
const x = startX + laneStep * idx;
const intensity = Math.min(1 + lane.weight * 0.35, 2.2);
const emphasis = Boolean(lane.isNew || lane.isHot);
const emphasis = Boolean(lane.isNew || lane.isHot || this.selectedRequesterFilter);
const laneGroup = layer.append('g').attr('class', 'crypto-lane');

const pNode = this.drawNode(laneGroup, x, topY, lane.process, 'process', intensity, lane.palette, emphasis);
Expand Down Expand Up @@ -1221,9 +1287,18 @@
.style('font-family', 'Share Tech Mono, monospace')
.style('font-size', '11px')
.style('fill', '#d2d9e5')
.text(this.selectedClientFilters.size
? `ACTIVE PATHS (${Array.from(this.selectedClientFilters).join(' + ')})`
: 'ACTIVE PATHS');
.text(
this.selectedClientFilters.size || this.selectedRequesterFilter
? `ACTIVE PATHS (${[
this.selectedClientFilters.size
? Array.from(this.selectedClientFilters).join(' + ')
: null,
this.selectedRequesterFilter
? `requester:${this.selectedRequesterFilter.name}`
: null
].filter(Boolean).join(' | ')})`
: 'ACTIVE PATHS'
);

lanes.slice(0, 8).forEach((lane, idx) => {
legend.append('text')
Expand Down Expand Up @@ -1251,7 +1326,7 @@
.attr('y', goneY + 16 + idx * 14)
.style('font-family', 'Share Tech Mono, monospace')
.style('font-size', '10px')
.style('fill', '#8e98a9')
.style('fill', '#8e98a9')
.text(`- ${item.label} (${age}s)`);
});
}
Expand Down
6 changes: 4 additions & 2 deletions static/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,12 @@ function initApp() {
// Setup event handlers
setupEventListeners();

// When nginx serves SPA fallback (/index.html) for /crypto,
// When nginx serves SPA fallback (/index.html) for crypto route aliases,
// open the dedicated crypto view automatically by route.
const path = String(window.location.pathname || '').replace(/\/+$/, '') || '/';
if (path === '/crypto' && window.kernelContextMenu && typeof window.kernelContextMenu.activateCryptoView === 'function') {
if ((path === '/crypto' || path === '/linux-crypto-subsystem')
&& window.kernelContextMenu
&& typeof window.kernelContextMenu.activateCryptoView === 'function') {
setTimeout(() => {
window.kernelContextMenu.activateCryptoView();
}, 140);
Expand Down
6 changes: 3 additions & 3 deletions static/js/right-semicircle-menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class RightSemicircleMenuManager {
activateOverlayView(itemId) {
if (itemId === 'scheduler') {
// Force hard navigation to dedicated SEO page.
window.location.assign('/crypto');
window.location.assign('/linux-crypto-subsystem');
return;
}
if (!window.kernelContextMenu) return;
Expand Down Expand Up @@ -348,7 +348,7 @@ class RightSemicircleMenuManager {
debugLog('🖱️ Click detected on item:', item.id, item.label);
event.stopPropagation(); // Prevent event bubbling
if (item.id === 'scheduler') {
window.location.assign('/crypto');
window.location.assign('/linux-crypto-subsystem');
return;
}
if (isOverlay) {
Expand All @@ -368,7 +368,7 @@ class RightSemicircleMenuManager {
event.preventDefault();
event.stopPropagation();
if (item.id === 'scheduler') {
window.location.assign('/crypto');
window.location.assign('/linux-crypto-subsystem');
return;
}
// Prevent re-rendering during click
Expand Down
Loading
Loading