Skip to content

feat(sensor): attribute runtime hits to live traffic route templates and auth state (#69) - #228

Merged
vsn411 merged 4 commits into
secfoo-com:mainfrom
SriRamkunamsetty:feat/route-auth-attribution-69
Nov 30, 2026
Merged

vsn411 merged 4 commits into
secfoo-com:mainfrom
SriRamkunamsetty:feat/route-auth-attribution-69

Conversation

@SriRamkunamsetty

Copy link
Copy Markdown
Contributor

Fixes #69

Summary

Adds live request, job, and auth state attribution for Python and Node.js probes while enforcing the privacy guarantee (route templates only — never concrete paths, query strings, header/cookie values, tokens, or user IDs):

  • Python (\contextvars.ContextVar, \src/secfoo/sensor/context.py\ & \probe.py):

    • Automatic zero-code framework hooks (when \SECFOO_SENSOR=1) + explicit middlewares (\SecfooASGIMiddleware\ for FastAPI/Starlette, \SecfooWSGIMiddleware\ / \install_flask\ for Flask, \SecfooDjangoMiddleware\ for Django), normalizing int:id patterns cleanly to {id}\ and defaulting unmatched routes to \unknown.
    • \job_context(name)\ helper for \job:\ background execution tagging.
    • \detect_auth_state()\ checking framework auth posture (\is_authenticated) and header/session cookie presence (never reading values).
    • Keyed hits by (fingerprint, symbol, route, auth)\ and counted per-route requests on sessions (
      outes_seen).
  • Node.js (\AsyncLocalStorage,
    pm/secfoo-sensor/):

    • \expressMiddleware()\ reading
      eq.baseUrl + req.route.path\ and \ astifyPlugin\ reading
      equest.routeOptions.url\ /
      outerPath.

    • unWithJob, \NodeHitCollector, template sanitization, and
      ode --test\ suite validated directly against \secfoo.runtime.evidence.validate_event.
  • Contract & Dashboard Integration:

    • Extended \evidence.schema.json,
      untime/evidence.py, \schema.sql,
      epository.py, and \web/sca_runtime.py\ with validated
      outes_seen\ storage and
      eached on X of Y routes seen\ summaries.

Benchmark & Verification

  • Node HTTP server (1,000 reqs): \1,818 rps\ bare vs \1,857 rps\ probed (-2.14%\ throughput loss, -0.61 ms\ p99 delta).
  • Python FastAPI (1,500 reqs) & Conformance Kit: \167.4 rps\ bare vs \184.3 rps\ probed; watched-call marginal overhead +0.84 us/call\ (budget \50 us), \6/6\ conformance checks passed.
  • Checks:
    uff check .\ clean, \�andit -c .bandit -ll -r src/secfoo\ clean, \pytest tests/test_sensor/ tests/test_runtime/ tests/test_web/test_sca_runtime.py tests/test_docs_consistency.py\ (322 passed).

Comment thread npm/secfoo-sensor/lib/context.js Fixed
Comment thread src/secfoo/web/sca_runtime.py Fixed
@vsn411
vsn411 merged commit 666bfe2 into secfoo-com:main Nov 30, 2026
16 checks passed
@github-actions

Copy link
Copy Markdown

Leaderboard update

SriRamkunamsetty now has 36 points (rank #2, Bronze). 14 more to reach Silver.

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.

Attribute runtime hits to live traffic (route, auth state)

3 participants