Feature #7785
openpcap-log: support packet context for conditional alerts
Description
Hi all,
Currently the pcap-log feature, when configured with `conditional: alerts`, only records the "golden packet" that triggered the alert. For analysis and forensic purposes, it would be valuable to also capture surrounding packets for context.
Proposed Enhancement:
Add configurable context packet capture with two new options:
- `context-packets-before: N` - capture N packets before the alert packet
- `context-packets-after: N` - capture N packets after the alert packet
Use Case:
This is essential for incident analysis where investigators need to see the complete flow context around an alert, not just the triggering packet. This helps understand attack patterns, data exfiltration, and protocol-level behavior.
Implementation Notes:
- Only applies to conditional logging modes (`alerts`/`tag`), not `all`
- "Before" packets stored in circular buffer during normal operation
- "After" packets tracked per-flow after alert triggers
- Maintains existing performance characteristics when context is disabled
The company I work for has a critical need for this feature and we're ready to invest development time. If there's no availability in the near term, I'm prepared to develop and maintain this feature myself, following project guidelines.
I'd appreciate feedback on the approach and any guidance on implementation preferences.