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): Upgradeverity view(plus--viewonverity scanandverity test) into a zero-signup, 100% air-gapped local Web Control Center & Report Explorer built on pure Pythonstdlib(ThreadingHTTPServer) and a zero-build modern ES module SPA packaged viaimportlib.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-onlylocks all mutating/executionPOSTendpoints (403 {"error": "READ_ONLY_MODE"}), and--allow-live-scanis 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, orVERITY_NO_BROWSER=1is set. Passing the 256-bitsecrets.token_urlsafe(32)capability token in the URL#token=fragment ensures it never travels over HTTP orRefererheaders; the SPA moves it intosessionStorage, strips the fragment viahistory.replaceState, and sendsX-Verity-View-Tokenon protected requests. - 4-Layer Localhost Security Gate:
- Strict Loopback Binding: Binds strictly to
127.0.0.1,::1, orlocalhost; passing0.0.0.0or any non-loopback--hostfails closed at CLI startup with exit code2. - Literal
HostAllowlist (DNS-Rebinding Defense): Rejects (403 Forbidden) any request whoseHostheader is not an exact literal match for127.0.0.1:<port>,localhost:<port>, or[::1]:<port>. Sec-Fetch-Site&OriginCross-Site Gate: Rejects (403 Forbidden) requests withSec-Fetch-Site: cross-siteorsame-site, and validatesOrigin(when present) matches exacthttp://127.0.0.1:<port>,http://localhost:<port>, orhttp://[::1]:<port>.- 256-Bit Session Token &
--read-onlyLock: VerifiesX-Verity-View-Tokenviasecrets.compare_digest()on everyPOSTroute (and all/api/v1/*routes when--strict-authis set), and blocks mutations when--read-onlyis 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, andReferrer-Policy: no-referrer.actions.pyuses typed in-process Python APIs with zeroshell=True, andindexer.pyplus every API response pass through_scrub_secrets()(redacting API keys, PEM blocks, and DSN credentials). - Concise 1-Line Terminal & Live SSE
ActivityLogBuffer(activity.py): OverridesBaseHTTPRequestHandler.log_message()so noisyGET 200static asset and/api/v1/healthpolling 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/eventswithactivity,scan_progress,artifact_added,artifact_updated, and: pingevery 15s). - Hero Quick-Launch Bar & 6 Full-Feature Control Views (100%
verity-redteam-coreParity): - 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
⌘KCommand Palette. - 1.
Findings & Reports: Multi-run selector (./artifacts,.,~/.verity/reports, plus offline drag-and-drop.json/.sarif/.jsonlviaFileReader), sortable semantic table, severity/scanner/client/CWE/OWASP/suppressed filters, slide-over Finding Inspector, 1-click.verity-baseline.jsonsuppress/unsuppress, inline# verity-ignore:copy, andJSON/Markdown/HTML/CycloneDX 1.6/SPDX 2.3exports. - 2.
Scan Studio: Visual builder for allverity scanflags (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-dialectSqlSecurityGuardAST workbench (postgres,mysql,sqlite,duckdb,tsql,bigquery,snowflake),apply_projection&LIKEsanitizer, 4 synthetic demo traps, live--url/--commandReadOnlyGuardprobes, 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/.verityignoreinspector. - 6.
Stream & MCP Server: Virtualizedmcp_stream.logJSONL timeline + live Backend Activity drawer, localverity serve(127.0.0.1:8765) health probe, and copyable IDE client config snippets. M40Pro Feature Gating &ViewerRegistryPlugin Hooks: Live SARIF export (GET /api/v1/runs/<id>/export?fmt=sarif) andPOST /api/v1/explainfail closed with structured403PRO_FEATURE_REQUIREDJSON (_pro_plugin_available()perM40) whenverity-prois absent, while offline viewing of user-supplied.sariffiles works in Free with zero LLM/network calls.ViewerRegistry(verity.plugins) exposesregister_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">+ CSSlight-dark()andcolor-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)(appendChildfallback) sorting,hidden="until-found"+beforematchdetail sub-tabs, IME-safeEnterhandling (event.isComposing || event.keyCode === 229), a single centralizedrole="status"live region, and stricttextContent/createElementDOM construction (zeroinnerHTMLsinks, zero externalhttp(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 |