Implementation:0xSteph Pentest ai Dashboard JS
| Knowledge Sources | |
|---|---|
| Domains | Frontend, Dashboard, Visualization |
| Last Updated | 2026-10-23 00:00 GMT |
Overview
Concrete tool for rendering a browser-based pentest engagement dashboard that polls the local FastAPI surface, provided by the pentest-ai API static assets.
Description
The dashboard.js file is a plain-vanilla JavaScript single-page dashboard with no build step. It polls the local FastAPI REST API at 4-second intervals, rendering engagements, findings (with severity filtering), attack chains, and a live event stream via WebSocket. It includes HTML escaping for all rendered content, health/version indicators, and tab navigation between engagements and findings views. Served same-origin only by the FastAPI static files mount at /dashboard.
Usage
This file is served as a static asset by the FastAPI server at /dashboard/. No import needed — it is loaded via a <script> tag in the dashboard HTML page. It automatically connects to the same-origin API.
Code Reference
Source Location
- Repository: 0xSteph_Pentest_ai
- File: api/static/dashboard.js
- Lines: 1-489
Signature
// IIFE module — no exports, attaches to DOM on load.
// State: engagements, findings, chains, health, WebSocket connection
// Poll interval: 4000ms
// API base: '' (same-origin)
const state = {
engagements: [],
selectedId: null,
selectedFindings: [],
selectedChains: [],
selectedSummary: null,
severityFilter: null,
activeTab: 'engagements',
healthOk: false,
pollTimer: null,
ws: null,
};
async function api(path, opts) { ... }
async function refreshHealth() { ... }
async function refreshEngagements() { ... }
async function selectEngagement(id) { ... }
Import
<!-- Loaded automatically when served by FastAPI at /dashboard/ -->
<script src="dashboard.js"></script>
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| /health | HTTP GET | Yes | Liveness check for connection status indicator |
| /version | HTTP GET | Yes | Version badge display |
| /engagements | HTTP GET | Yes | Engagement list polling |
| /engagements/{id}/findings | HTTP GET | Yes | Findings for selected engagement |
| /engagements/{id}/chains | HTTP GET | Yes | Attack chains for selected engagement |
| /engagements/{id}/stream | WebSocket | No | Live event stream (findings, summary) |
Outputs
| Name | Type | Description |
|---|---|---|
| DOM updates | HTML | Rendered engagement table, findings list, chain viewer, health indicator |
Usage Examples
Running the Dashboard
# Start the API server
uvicorn api.server:app --host 0.0.0.0 --port 8000
# Open the dashboard in a browser
# http://localhost:8000/dashboard/