Skip to content

fix: add panic recovery in distributor event pipeline#7

Merged
Neo23x0 merged 1 commit intoNextron-Labs:masterfrom
RuneCode14:test/adversarial-edge-cases
Mar 14, 2026
Merged

fix: add panic recovery in distributor event pipeline#7
Neo23x0 merged 1 commit intoNextron-Labs:masterfrom
RuneCode14:test/adversarial-edge-cases

Conversation

@RuneCode14
Copy link
Copy Markdown

Problem

A panicking consumer crashes the entire event loop. If a Sigma rule evaluation, IOC regex match, or any consumer's HandleEvent hits a nil pointer or other panic, Aurora dies — no more events processed, no graceful recovery.

This is the kind of bug you don't find with happy-path tests. It requires adversarial testing with a deliberately broken consumer.

Fix

Wrapped each consumer's HandleEvent call in safeHandleEvent() with defer recover():

  • Panic is caught and returned as an error
  • Error is logged with the consumer name
  • Remaining consumers still receive the event
  • Distributor continues processing subsequent events

Test

TestDistributorPanicRecovery: registers a panicking consumer before a counting consumer, sends an event through the replay provider, and verifies:

  1. The counting consumer still receives the event (panic didn't kill the loop)
  2. d.Processed() increments (distributor kept running)

All tests pass

ok  github.com/Nextron-Labs/aurora-linux/lib/distributor  0.005s
ok  github.com/Nextron-Labs/aurora-linux/lib/consumer/sigma  0.005s

A panicking consumer (e.g. due to a nil pointer in a Sigma rule
evaluation or IOC regex engine) would crash the entire event loop,
killing Aurora. This wraps each consumer's HandleEvent in a deferred
recover so that:

1. The panic is caught and logged as an error
2. Remaining consumers still receive the event
3. The distributor continues processing subsequent events

Added TestDistributorPanicRecovery: registers a deliberately panicking
consumer before a counting consumer, sends an event, and verifies the
counter still increments.
@Neo23x0 Neo23x0 merged commit ca1eab0 into Nextron-Labs:master Mar 14, 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