Repository navigation
feat(runtime): add per-project Runtime dashboard, live polling, and alert webhooks - #212
Open
SriRamkunamsetty wants to merge 1 commit into
Open
SriRamkunamsetty wants to merge 1 commit into
SriRamkunamsetty wants to merge 1 commit into
Conversation
vsn411
requested changes
Nov 29, 2026
vsn411
left a comment
Collaborator
There was a problem hiding this comment.
Thanks, and welcome! The Runtime page is a big step for #72. Sensor health with a stale state after 3 missed heartbeats, coverage, new packages and newly reached functions are exactly what the issue asks for. The webhook payload deliberately leaves out stack samples, and the polling script is CSP-clean.
Some changes are needed in the alert path before we merge, because it currently runs inside the request handlers:
- Ingest blocks the event loop.
post_eventsisasync, but_notify_newly_reachedruns synchronously inside it. It reads everyruntime_evidencerow for the project on each batch with hits, and callsemit_alertonce per row. Each call does anINSERT … ; commit, and possibly a blockingurlopenwith a 5 s timeout. Evidence grows without bound, so a busy sensor will slow down, and every other request waits while the webhook POST runs. Suggestions:- only look at fingerprints that are new in this batch, e.g. a SQL anti-join against
runtime_alerts_sent; - send the webhook off the event loop (
BackgroundTasks, or a small worker thread).
- only look at fingerprints that are new in this batch, e.g. a SQL anti-join against
- A GET can fire a webhook. The
sensor_stalealert is emitted while/projects/{id}/runtime(and the 10 s.jsonpoll) renders. Viewing a page shouldn't have side effects, and with the page closed nobody gets the alert. Detect staleness where heartbeats are processed, or in a periodic check, rather than in the dashboard builder. _claim_alertcommits the caller's connection. Called mid-ingest, it commits whatever the ingest had pending. Let the caller own the transaction.- Don't log the webhook URL.
logger.warning("… failed for %s", url)writes the full URL, and Slack/Teams-style URLs carry their secret token in the path. Log the host only.
Small things:
runtime/api.pynow imports private helpers fromweb/(_vulnerability_key,_is_request_route). Moving them to a shared module would keepruntimeindependent of the web layer.- #213 (yours too) also changes
routes/projects.pyandproject.html, so whichever merges second will need a rebase.
CI hasn't run yet because this is your first PR here. A maintainer will approve the workflow run.
This was referenced Nov 29, 2026
SriRamkunamsetty
force-pushed
the
feat/runtime-dashboard-72
branch
from
November 30, 2026 01:57
059909c to
3e044da
Compare
Contributor
Author
|
Addressed all review feedback and rebased onto \main:
|
| secret_url = "https://hooks.example.com/services/SECRET_WORKSPACE/SECRET_TOKEN" | ||
| with caplog.at_level(logging.WARNING, logger="secfoo.runtime.alerts"): | ||
| post_webhook(secret_url, {"event": "sensor_stale"}) | ||
| assert "hooks.example.com" in caplog.text |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #72
Summary
/projects/{id}/runtime, linked fromproject.html):src/secfoo/web/runtime_dashboard.pycomputing connected sensor health (healthy vs Stale after missing >= 3 heartbeats), events/min, dropped event totals, observation windows, function execution coverage (app_functions_executed / app_functions_total), routes observed, newly loaded packages, version drift / unscanned / new advisory findings, and newly reached vulnerable functions linking directly to SCA finding details./projects/{id}/runtimeand/projects/{id}/runtime.jsonroutes insrc/secfoo/web/routes/projects.pyplus templatesprojects_runtime.html,project.html, and CSP-clean external scriptsrc/secfoo/web/static/js/runtime-live.js(polling every 10s while the tab is visible).[runtime] alert_webhook):[runtime] alert_webhookinsrc/secfoo/settings.py.src/secfoo/runtime/alerts.py+runtime_alerts_sentdeduplication table inschema.sql, emitting sanitized webhook payloads (withfinding_fingerprint,app,env, and deeplink, never stack samples) forreached_from_traffic(runtime/api.py),new_advisory(runtime/inventory.py), andsensor_stale(runtime_dashboard.py, reset on fresh heartbeat).[runtime] alert_webhookand/projects/<id>/runtimeindocs/REFERENCE.md.tests/test_web/test_runtime_dashboard.py.Verification
ruff check .— 0 errorsbandit -c .bandit -ll -r src/secfoo— 0 medium/high issuespytest tests/test_web/test_runtime_dashboard.py tests/test_runtime tests/test_web/test_no_inline_scripts.py tests/test_web/test_routes.py tests/test_docs_consistency.py -q— 231 passed