Skip to content

Live-replay: real users + varied scores via Simulate feed; mode-switcher & consumer fixes - #30

Merged
cheeseburden merged 8 commits into
cheeseburden:mainfrom
brijesh-shetty:fix/live-replay-simulate-feed
Jun 20, 2026
Merged

Live-replay: real users + varied scores via Simulate feed; mode-switcher & consumer fixes#30
cheeseburden merged 8 commits into
cheeseburden:mainfrom
brijesh-shetty:fix/live-replay-simulate-feed

Conversation

@brijesh-shetty

Copy link
Copy Markdown
Contributor

Summary

Fixes the live-replay dashboard showing every event as unknown / connection with a
constant score. Live-replay now streams the labelled test_events.json through the
existing Simulate path, so the AI engine scores real users (USR-XXXX) with varied,
model-driven anomaly scores
. Also hardens the dashboard mode switcher and the Kafka
consumer, and documents both. Merged with the latest upstream/main (pipeline-reset
work) with conflicts resolved.

Why

The Zeek/pcap stream produces events with random Zeek UIDs and no user identity, so the
uid → event_id enrichment never matched → constant 30.3% / unknown. The labelled
Simulate stream carries identity with each event, which is what the model needs.

Changes

  • simulate.py — single shared producer (was one producer per WS connection, so each
    browser refresh compounded the event rate ~+60/refresh). Producer stops when no
    dashboard is connected.
  • kafka_client.py — consumer seeks to the latest offset on connect and throttles
    the UI feed instead of the consumer, so a restart/switch shows current events
    instead of draining hours of stale backlog.
  • docker-compose.ymlzeek + filebeat gated behind the live-replay profile
    (off by default); the identity-less raw Zeek stream is now opt-in.
  • mode_switcher.py — dashboard Live/Portal toggle: fast up -d switch (no rebuild),
    current_mode() detects via hpe-es-to-kafka, live switch no longer starts the Zeek
    replay; silenced /status poll tracebacks; ngrok restart: unless-stopped.
  • scripts/generate_conn_log_from_test_events.py — optional helper to build a
    conn.log with uid = event_id for the opt-in raw replay path.
  • README — documents the mode switcher, the per-mode feed, and the profile gating.

Testing

  • docker compose -f docker-compose.yml up -d → dashboard shows real USR-XXXX with
    varied scores at ~2 events/sec; rate stays steady across browser refreshes.
  • Portal mode stays quiet (only real logins).
  • Backend files compile; conflict resolution keeps both the fork's reset logic and
    upstream's Redis live-counter reset.

Merge notes

Merged upstream/main and resolved conflicts in admin.py (kept both reset paths) and
App.jsx (kept the new animation + upstream's resetInProgressRef guard).

…ne bugs

- Add portal-only environment configs (docker-compose.portal.yml, run-portal.bat).
- Add zeek-conn-* ES index wiping to confirm_reset to clear connection logs.
- Conditionally skip write_zeek_log in /simulate when running in portal-only mode.
- Retain event.event_id to enable frontend-side deduplication.
- Restore ALLOW events to frontend pipeline logs and add green packet animations.
- Abbreviate IPv6 addresses in Alert Cards and Event Logs using formatIpShort.
- Remove StrictMode from main.jsx to prevent duplicate WS connections.
- Add PORTAL_ONLY_MODE environment variable configuration
- Guard Zeek log writing in auth routes to skip during portal-only mode
- Maintain WebSocket connection behavior in simulate routes based on portal flag
- Refactor Kafka client connectivity checks to gracefully handle portal-only environments
simulate.py: stream test_events during live-replay, 0.5s delay, heartbeat to stop zombie loops; threat_engine.py: real latencies for Kafka + Cred Rotation stages; Header.jsx + index.css: MODE Live Replay/Portal toggle; mode_switcher.py: host agent for compose down/up
…itch

- mode_switcher.py: catch ConnectionAborted/Reset/BrokenPipe in _json so
  browser-closed /status polls do not dump WinError 10053 tracebacks
- docker-compose.portal.yml: add restart: unless-stopped to ngrok so it
  self-recovers from the ERR_NGROK_334 endpoint race on fast down->up switches
…+ seek-latest

- simulate.py: single shared producer (was one per WS connection, so refresh compounded the event rate)

- kafka_client.py: consumer seeks to latest on connect and throttles the UI feed, not the consumer (no more stale-backlog draining)

- docker-compose.yml: gate zeek/filebeat behind the live-replay profile (raw Zeek events have no user identity)

- mode_switcher.py: plain 'up -d' switch, detect mode via hpe-es-to-kafka, live switch no longer starts the Zeek replay

- add generate_conn_log_from_test_events.py; document the mode switcher in README
…ulate-feed

# Conflicts:
#	backend/app/routes/admin.py
#	frontend/src/App.jsx
@cheeseburden
cheeseburden merged commit 1bbb999 into cheeseburden:main Jun 20, 2026
7 checks passed
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.

2 participants