Skip to content

tests: verify pcap_filename on alert and flow events - v3#3013

Open
oferda4 wants to merge 1 commit intoOISF:masterfrom
oferda4:test/eve-pcap-filename-alert-and-flow
Open

tests: verify pcap_filename on alert and flow events - v3#3013
oferda4 wants to merge 1 commit intoOISF:masterfrom
oferda4:test/eve-pcap-filename-alert-and-flow

Conversation

@oferda4
Copy link
Copy Markdown

@oferda4 oferda4 commented Apr 7, 2026

Add a regression test that checks the pcap_filename field is present and correct in EVE JSON output for both alert events (packet-based) and flow events (non-packet-based).

These two code paths use different sources for the filename in OutputJsonBuilderBuffer: per-packet pfv->filename when a packet is available, and the global PcapFileGetFilename() fallback for flow/netflow events where no packet exists.

Previous PR: #2932

v2:
- Fix recursive test and readme.

v3:

  • Add stats event coverage to pcap-filename-alert-and-flow (exercises the p == NULL, f == NULL global fallback path in OutputJsonBuilderBuffer)
  • Fix misleading comment in pcap-filename-recursive about processing order; order is by mtime, not guaranteed lphabetical.

Redmine ticket: https://redmine.openinfosecfoundation.org/issues/5255
Suricata PR: OISF/suricata#15176

Comment thread tests/pcap-filename-recursive/README.md Outdated
Verify that pcap_filename in EVE JSON output reflects the file each
connection's packets came from, not the last file the RX thread processed.

Two pcap files are fed with --pcap-file-recursive. alert.pcap is processed
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You said

the order is actually determined by readdir() - which is filesystem-dependent and not guaranteed.

So ? (or can we make the order reproducible)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right but the test outcome is deterministic: regardless of order, one pcap's flow events would get the wrong pcap_filename if the global fallback were used instead of the per-flow pfv. I'll update the README to not claim a specific order 👍

Copy link
Copy Markdown
Collaborator

@catenacyber catenacyber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Besides the nit comment, I think these tests are good

@oferda4
Copy link
Copy Markdown
Author

oferda4 commented Apr 11, 2026

Besides the nit comment, I think these tests are good

@catenacyber How do you go with small fixes like that? Should I open a new PR version?

@inashivb
Copy link
Copy Markdown
Member

Besides the nit comment, I think these tests are good

@catenacyber How do you go with small fixes like that? Should I open a new PR version?

It's ok to force-push minor changes on suricata-verify PRs. Thanks for asking and following contribution guidelines! 🙇🏽‍♀️ 🌟

Add three suricata-verify tests that together cover all code paths in
the pcap_filename output for pcap-file mode:

pcap-filename-alert-and-flow: single pcap, verifies pcap_filename is
present in alert events (p != NULL path in OutputJsonBuilderBuffer) and
flow events (p == NULL, falls back to FlowGetPcapFileVars).

pcap-filename-pseudo-pkts: verifies pcap_filename is present in fileinfo
events generated by stream pseudo-packets (PKT_SRC_STREAM_TCP_DETECTLOG_FLUSH),
which carry pcap_v.pfv propagated from the flow.

pcap-filename-recursive: two pcap files fed with --pcap-file-recursive.
alert.pcap is processed first; http.pcap is processed last. Verifies that
the flow event for the alert.pcap connection still reports alert.pcap
(via the per-flow pfv), not the stale global that has advanced to http.pcap.
This is the primary race-condition regression test for #5255.

Ticket: #5255
@oferda4 oferda4 force-pushed the test/eve-pcap-filename-alert-and-flow branch from de845a4 to bae5324 Compare April 11, 2026 07:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

requires suricata pr Depends on a PR in Suricata

Development

Successfully merging this pull request may close these issues.

3 participants