Skip to content

M47 (TASK-83-FREE): Zero-Signup Local Web Control Center & Report Explorer (verity view)

Purpose & Architectural Decisions

  • Interactive-by-Default Loopback Web Control Center (verity view): Upgrade verity view (plus --view on verity scan and verity test) into a zero-signup, 100% air-gapped local Web Control Center & Report Explorer built on pure Python stdlib (ThreadingHTTPServer) and a zero-build modern ES module SPA packaged via importlib.resources. Interactive UI controls are active by default on loopback (127.0.0.1:8766, auto-falling back to an OS-assigned free port unless --strict-port); --read-only locks all mutating/execution POST endpoints (403 {"error": "READ_ONLY_MODE"}), and --allow-live-scan is retained as a backward-compatible no-op alias.
  • Session URL Bootstrap & Auto-Open: On startup, the CLI prints a launch banner with the clickable http://127.0.0.1:<port>/#token=<token> URL and opens the default browser automatically unless --no-open, CI=true, or VERITY_NO_BROWSER=1 is set. Passing the 256-bit secrets.token_urlsafe(32) capability token in the URL #token= fragment ensures it never travels over HTTP or Referer headers; the SPA moves it into sessionStorage, strips the fragment via history.replaceState, and sends X-Verity-View-Token on protected requests.
  • 4-Layer Localhost Security Gate:
  • Strict Loopback Binding: Binds strictly to 127.0.0.1, ::1, or localhost; passing 0.0.0.0 or any non-loopback --host fails closed at CLI startup with exit code 2.
  • Literal Host Allowlist (DNS-Rebinding Defense): Rejects (403 Forbidden) any request whose Host header is not an exact literal match for 127.0.0.1:<port>, localhost:<port>, or [::1]:<port>.
  • Sec-Fetch-Site & Origin Cross-Site Gate: Rejects (403 Forbidden) requests with Sec-Fetch-Site: cross-site or same-site, and validates Origin (when present) matches exact http://127.0.0.1:<port>, http://localhost:<port>, or http://[::1]:<port>.
  • 256-Bit Session Token & --read-only Lock: Verifies X-Verity-View-Token via secrets.compare_digest() on every POST route (and all /api/v1/* routes when --strict-auth is set), and blocks mutations when --read-only is active.
  • Zero-Inline Strict CSP, Safe Execution & Secret Scrubbing: Static assets enforce Content-Security-Policy: default-src 'none'; script-src 'self'; style-src 'self'; img-src 'self' data:; connect-src 'self'; font-src 'self'; object-src 'none'; base-uri 'none'; frame-ancestors 'none'; form-action 'self', X-Content-Type-Options: nosniff, and Referrer-Policy: no-referrer. actions.py uses typed in-process Python APIs with zero shell=True, and indexer.py plus every API response pass through _scrub_secrets() (redacting API keys, PEM blocks, and DSN credentials).
  • Concise 1-Line Terminal & Live SSE ActivityLogBuffer (activity.py): Overrides BaseHTTPRequestHandler.log_message() so noisy GET 200 static asset and /api/v1/health polling logs never clutter the terminal. Every meaningful action (READY, DISCOVER, SCAN, SQL-GUARD, LOOKUP, DEMO, BASELINE, EXPORT) is sanitized of ANSI/control characters (\x00–\x1f, \x7f) and secrets via _scrub_secrets(), printed as a single concise timestamped line, stored in a thread-safe 500-event ring buffer (GET /api/v1/activity), and streamed live over SSE (GET /api/v1/events with activity, scan_progress, artifact_added, artifact_updated, and : ping every 15s).
  • Hero Quick-Launch Bar & 6 Full-Feature Control Views (100% verity-redteam-core Parity):
  • Hero Quick-Launch Bar: Top 1-click workflows for Audit My Workstation, Scan Project/Path (with presets), Run 4-Target Demo Sandbox, and Quick SQL / CVE / Endpoint Check, plus a ⌘K Command Palette.
  • 1. Findings & Reports: Multi-run selector (./artifacts, ., ~/.verity/reports, plus offline drag-and-drop .json/.sarif/.jsonl via FileReader), sortable semantic table, severity/scanner/client/CWE/OWASP/suppressed filters, slide-over Finding Inspector, 1-click .verity-baseline.json suppress/unsuppress, inline # verity-ignore: copy, and JSON/Markdown/HTML/CycloneDX 1.6/SPDX 2.3 exports.
  • 2. Scan Studio: Visual builder for all verity scan flags (17 IDE/Agent clients, --scan-global, composable --scanners, --typosquat-threshold, --call-analysis/--reachable-only, --live-probe, --offline, --compliance owasp-mcp-top-10, --fail-on-severity) with a live equivalent CLI & GitHub Action YAML copy box.
  • 3. SQL & Runtime Guards: 7-dialect SqlSecurityGuard AST workbench (postgres, mysql, sqlite, duckdb, tsql, bigquery, snowflake), apply_projection & LIKE sanitizer, 4 synthetic demo traps, live --url/--command ReadOnlyGuard probes, UCP rug-pull hash save/diff, and [Pro] showcase cards.
  • 4. Passports & CVEs: Interactive offline search across 6,062+ MCP Server Passports (FingerprintMatcher, HybridDiscoveryMatcher) and 856+ OSV v1.6.0 Advisories (VulnerabilityLookupEngine).
  • 5. SBOM, Drift & Baseline: OWASP MCP Top 10 compliance scorecard, searchable CycloneDX 1.6 / SPDX 2.3 SBOM component table, inventory drift snapshot save/diff, and .verity-baseline.json / .verityignore inspector.
  • 6. Stream & MCP Server: Virtualized mcp_stream.log JSONL timeline + live Backend Activity drawer, local verity serve (127.0.0.1:8765) health probe, and copyable IDE client config snippets.
  • M40 Pro Feature Gating & ViewerRegistry Plugin Hooks: Live SARIF export (GET /api/v1/runs/<id>/export?fmt=sarif) and POST /api/v1/explain fail closed with structured 403 PRO_FEATURE_REQUIRED JSON (_pro_plugin_available() per M40) when verity-pro is absent, while offline viewing of user-supplied .sarif files works in Free with zero LLM/network calls. ViewerRegistry (verity.plugins) exposes register_artifact_parser, register_api_route, and optional Pro tab renderers.
  • Native 2026 Web Platform Primitives (modern-web-guidance): <meta name="color-scheme" content="light dark"> + CSS light-dark() and color-mix(in oklab, ...) theme tokens, native <dialog closedby="any"> + showModal() (overscroll-behavior: contain + Safari pointer-bounds fallback), [popover="auto"] flyouts & [popover="manual"] toasts, tbody.moveBefore(row, null) (appendChild fallback) sorting, hidden="until-found" + beforematch detail sub-tabs, IME-safe Enter handling (event.isComposing || event.keyCode === 229), a single centralized role="status" live region, and strict textContent / createElement DOM construction (zero innerHTML sinks, zero external http(s):// CDN references).

Target Files

File Change
src/verity/viewer/__init__.py ViewerRegistry plugin hook (register_artifact_parser, register_api_route, Pro tab slots)
src/verity/viewer/activity.py Thread-safe 500-event ActivityLogBuffer, concise 1-line CLI formatter, ANSI/control-char + _scrub_secrets() sanitization
src/verity/viewer/indexer.py Content-signature classifier (verity.scan.v1, verity.test.v1, verity.sbom.v1, verity.stream.jsonl, .sarif), pagination, secret scrubbing
src/verity/viewer/actions.py Zero-shell=True in-process action runners (scan, test, guard-sql, lookup, baseline, mcp-status) with SSE progress
src/verity/viewer/server.py Loopback ThreadingHTTPServer, 4-layer security gate, REST + SSE /api/v1/* router, silent static HTTP logs
src/verity/viewer/static/ Zero-build ES module SPA (index.html, style.css, app.js, components/*.js, views/*.js) bundled via importlib.resources
src/verity/cli.py verity view (--host, --port, --strict-port, --watch, --read-only, --strict-auth, --no-open, --allow-live-scan) + --view on scan/test
pyproject.toml Package data inclusion for verity.viewer static assets (static/**/*)
docs/cli/web-viewer.md Dedicated customer documentation portal guide (>= 180 lines) + mkdocs.yml nav entry
tests/unit/viewer/test_viewer_server.py Loopback binding, 4-layer security gate, indexer/pagination/scrubbing, SSE, activity.py, and M40 Pro-gate tests
tests/unit/viewer/test_viewer_actions_and_ui.py Action runner (scan/test/guard-sql/lookup/baseline), ViewerRegistry, importlib.resources packaging, zero-CDN, and XSS-safety tests

REST & SSE API Surface

Endpoint Method Auth Purpose
/ & /static/* GET Loopback + Host Serves bundled zero-build ES module SPA via importlib.resources with strict CSP.
/api/v1/health GET Loopback + Host (+Token if --strict-auth) Returns {ok, version, pro_enabled, loaded_plugins, read_only, watch_enabled, artifact_count, workspace_root, capabilities}.
/api/v1/runs GET Loopback + Host Lists indexed artifacts (verity.scan.v1, verity.test.v1, verity.sbom.v1, verity.stream.jsonl, .sarif, Pro kinds) with posture KPIs.
/api/v1/runs/<id> GET Loopback + Host Returns secret-scrubbed run detail (?offset=&limit= pagination for large streams/findings).
/api/v1/runs/<id>/export GET Loopback + Host Downloads fmt=json|md|html|cyclonedx|spdx (fmt=sarif enforces M40 PRO_FEATURE_REQUIRED 403 when verity-pro is absent).
/api/v1/activity GET Loopback + Host Returns bounded 500-entry ActivityLogBuffer (?since_id=).
/api/v1/events GET Loopback + Host text/event-stream pushing activity, scan_progress, artifact_added, artifact_updated, and : ping every 15s.
/api/v1/actions/scan POST X-Verity-View-Token + not --read-only Runs verity scan in-process (17 clients, composable scanners, OWASP, SBOM, drift, offline/live-probe), saves report, indexes it, emits activity + SSE progress.
/api/v1/actions/test POST X-Verity-View-Token + not --read-only Runs --demo synthetic targets, live --url / --command ReadOnlyGuard probes, or UCP rug-pull hash save/diff.
/api/v1/actions/guard-sql POST X-Verity-View-Token + not --read-only Executes 7-dialect SqlSecurityGuard validation, apply_projection, and LIKE/input sanitization.
/api/v1/actions/lookup POST X-Verity-View-Token + not --read-only Queries FingerprintMatcher (6,062+ passports) and VulnerabilityLookupEngine (856+ OSV advisories).
/api/v1/actions/baseline POST X-Verity-View-Token + not --read-only Suppresses/unsuppresses a finding fingerprint in .verity-baseline.json (or saves inventory baseline) and refreshes posture counts.
/api/v1/actions/mcp-status GET Loopback + Host Probes local verity serve (127.0.0.1:8765/health) and returns copyable client registration JSON snippets.
/api/v1/explain POST X-Verity-View-Token Pro plugin route (ViewerRegistry); returns structured PRO_FEATURE_REQUIRED (403) JSON in Free-only environments.

ATDD Traceability Matrix

AC ID Acceptance Criterion Paired Benign / Negative Control Verification Tier Test Target
AC-47.1 verity view binds loopback only, rejects non-loopback --host (exit 2), supports ephemeral port fallback vs --strict-port, respects --no-open/CI/VERITY_NO_BROWSER, and wires --view on scan/test. Default 127.0.0.1 binds cleanly with ephemeral fallback; valid --no-open skips browser launch cleanly. unit tests/unit/viewer/test_viewer_server.py::test_loopback_binding_and_cli_flags
AC-47.2 4-layer security gate enforces literal Host DNS-rebinding 403, Sec-Fetch-Site/Origin 403, zero-inline strict CSP headers, #token= fragment bootstrap + X-Verity-View-Token via compare_digest, and --read-only lock. Valid loopback Host (127.0.0.1:<port>), Sec-Fetch-Site: same-origin, and valid token succeed. unit tests/unit/viewer/test_viewer_server.py::test_security_gate_csp_and_tokens
AC-47.3 ArtifactIndex classifies verity.scan.v1, verity.test.v1, verity.sbom.v1, verity.stream.jsonl, and .sarif artifacts with ?offset=&limit= pagination and _scrub_secrets() redaction of API keys, PEM blocks, and DSN credentials. Empty directory returns clean empty paginated index; benign payloads are preserved uncorrupted. unit tests/unit/viewer/test_viewer_server.py::test_indexer_classification_pagination_and_scrubbing
AC-47.4 Interactive Control Center POST /api/v1/actions/{scan,test,guard-sql,lookup,baseline} execute deterministically in-process; live SARIF export & /api/v1/explain return M40 403 PRO_FEATURE_REQUIRED without verity-pro, while offline .sarif viewing succeeds. Benign SQL SELECT and clean configs pass without false positives; valid exports (json, md, html, cyclonedx, spdx) succeed. unit tests/unit/viewer/test_viewer_actions_and_ui.py::test_interactive_actions_and_pro_gates
AC-47.5 ActivityLogBuffer emits concise 1-line terminal logs (ANSI/control-char & secret scrubbed, silent static GET and /api/v1/health), serves /api/v1/activity, and pushes SSE /api/v1/events (activity, scan_progress, artifact_added, : ping). Static .js/.css and /api/v1/health fetches produce zero terminal log lines. unit tests/unit/viewer/test_viewer_server.py::test_activity_log_and_sse_events
AC-47.6 importlib.resources resolves bundled verity.viewer SPA static assets with zero external http(s):// CDN links, zero innerHTML sinks in static/**/*.js, and required native HTML/UI landmarks (<dialog>, [popover], light-dark(), 6 views). Built wheel asset listing includes all static/ files and loads offline with zero network egress. unit tests/unit/viewer/test_viewer_actions_and_ui.py::test_static_packaging_csp_and_xss_safety
AC-47.7 ViewerRegistry (verity.plugins) supports dynamic extension via register_artifact_parser and register_api_route without breaking Free-only startup. Empty plugin registry starts cleanly with zero errors and built-in Free parsers intact. unit tests/unit/viewer/test_viewer_actions_and_ui.py::test_viewer_registry_extensibility
AC-47.8 All repo quality, parity, and documentation portal gates pass (pytest, ruff check src tests scripts, build_docs_portal.py --check, mkdocs build --strict). Clean workspace reports zero drift and zero lint/link failures. gate uv run pytest tests/ && uv run ruff check src tests scripts && uv run mkdocs build --strict