Skip to content

feat(runtime): correlate live sensor traffic with threat-model entry points - #213

Merged
vsn411 merged 2 commits into
secfoo-com:mainfrom
SriRamkunamsetty:feat/threat-model-live-correlation-70
Nov 29, 2026
Merged

vsn411 merged 2 commits into
secfoo-com:mainfrom
SriRamkunamsetty:feat/threat-model-live-correlation-70

Conversation

@SriRamkunamsetty

Copy link
Copy Markdown
Contributor

Fixes #70

Summary

  • Machine-readable Entry Points in Threat Modeling:
    • Updated THREAT_MODELING_OUTPUT_CONTRACT (## 2. Scope & Assets) in src/secfoo/skills/renderer.py to include the En Entry Points table cross-referencing Bn trust boundaries.
    • Added extract_entry_points() and extract_trust_boundaries() in src/secfoo/report/architecture.py (gracefully returning [] / {} on older reports without the table).
  • Live traffic correlation engine (src/secfoo/runtime/correlation.py):
    • Implemented match_route() supporting exact routes, optional HTTP methods, templated segments ({id}, <id>, :id), and prefix wildcards (*).
    • Implemented correlate_project_traffic() mapping observed sensor request routes in runtime_evidence against En entry points, identifying live entry points, flagging unmodeled routes (threat-model drift), marking threats on live boundaries seen_in_production, and prioritizing live-boundary Gap threats first.
  • Dashboard & run UI integration:
    • Surfaced live/unmodeled entry points and Seen in production markers on the Threat Modeling run page (run_detail.html), project page (project.html, including a re-run threat-modeling trigger passing unmodeled routes as context), and Threat Modeling dashboard (threat_modeling_dashboard.html).
    • Surfaced boundary citations (e.g. Reached via E1 (B1: Internet -> API)) on SCA findings (sca_vulnerabilities_list.html and sca_vulnerability_detail.html).
  • Tests:
    • Added comprehensive tests in tests/test_web/test_threat_model_correlation.py.

Verification

  • ruff check . — 0 errors
  • bandit -c .bandit -ll -r src/secfoo — 0 medium/high issues
  • pytest tests/test_web/test_threat_model_correlation.py tests/test_web/test_threat_modeling_dashboard.py tests/test_web/test_widget_info_tips.py tests/test_web/test_sca_vulnerability_route.py tests/test_web/test_no_inline_scripts.py tests/test_web/test_run_ui.py tests/test_web/test_routes.py tests/test_docs_consistency.py -q — 109 passed

@vsn411

vsn411 commented Nov 29, 2026

Copy link
Copy Markdown
Collaborator

Thanks, and welcome! The correlation is clean:

  • match_route handles templated segments and prefix wildcards;
  • older threat models without an Entry Points table degrade to [];
  • unmodeled routes come only from the sensor's route templates (ingest already rejects concrete URLs).

The re-run button reuses the dashboard's existing background-run pattern behind the Origin check.

Small notes, none blocking:

  • correlate_project_traffic() now runs on every project page load and every run page load. If it re-parses the threat-model report each time, consider caching it per run the way other dashboards do.
  • The re-run note writes the routes inside backticks. A route containing a backtick would break the Markdown. Stripping backticks, and capping the list (e.g. 50 routes), would keep the prompt tidy.
  • feat(runtime): add per-project Runtime dashboard, live polling, and alert webhooks #212 (yours too) also changes routes/projects.py and project.html, so whichever merges second will need a rebase. Happy to help with it.

Once a maintainer approves the workflow run and CI is green, this is ready to merge.


routes = [str(r["route"]) for r in corr.unmodeled_routes]
if not routes:
return RedirectResponse(f"/projects/{project_id}", status_code=303)
shutil.rmtree(note_dir, ignore_errors=True)

threading.Thread(target=_run_and_cleanup, daemon=True).start()
return RedirectResponse(f"/projects/{project_id}?tm_rerun=started", status_code=303)
@vsn411
vsn411 merged commit 6533c18 into secfoo-com:main Nov 29, 2026
16 checks passed
@vsn411

vsn411 commented Nov 29, 2026

Copy link
Copy Markdown
Collaborator

Merged, thank you, and congratulations on your first contribution to secfoo! 🎉 The threat model and live traffic now meet: entry points, unmodeled routes and "seen in production" markers, which closes #70.

I merged current main before merging, and CI was green. The small notes above (caching the correlation per run, stripping backticks and capping the route list in the re-run note) would make a nice follow-up whenever you like.

@github-actions

Copy link
Copy Markdown

Leaderboard update

SriRamkunamsetty now has 10 points (rank #9). 15 more to reach Bronze.

Full leaderboard

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Correlate live traffic with the threat model's entry points

3 participants