Skip to content

detect: add tcp.session keyword for unified TCP lifecycle matching - v5 - #15962

Open
yashda wants to merge 1 commit into
OISF:mainfrom
yashda:feat/tcp-session-keyword
Open

detect: add tcp.session keyword for unified TCP lifecycle matching - v5#15962
yashda wants to merge 1 commit into
OISF:mainfrom
yashda:feat/tcp-session-keyword

Conversation

@yashda

@yashda yashda commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Make sure these boxes are checked accordingly before submitting your Pull Request -- thank you.

Contribution style:

Our Contribution agreements:

Changes (if applicable):

Link to ticket: https://redmine.openinfosecfoundation.org/issues/

Describe changes:

Note: Previously #15940

Introduce the tcp.session: keyword that accepts a comma-separated subset of {setup, established, closing} and matches packets whose TCP session state falls within the named phases.

This lets a rule writer cover the full TCP lifecycle in one rule instead of separate flow:not_established + flow:established rules.

Changes:

  • New detect-tcp-session.{c,h} with parser, match function, unit tests
  • Register DETECT_TCP_SESSION in detect-engine-register.{c,h}
  • Add to Makefile.am source list
  • Extend engine-analyzer text output for tcp.session:
  • Extend firewall.json keyword_info with tcp_session phase values
  • Update flow-keywords.rst documentation
  • Require TCP protocol and SIG_FLAG_REQUIRE_PACKET at setup

Ticket: 7704

Provide values to any of the below to override the defaults.

  • To use a Suricata-Verify or Suricata-Update pull request,
    link to the pull request in the respective _BRANCH variable.
  • Leave unused overrides blank or remove.

SV_REPO=
SV_BRANCH=OISF/suricata-verify#3156
SU_REPO=
SU_BRANCH=

Introduce the tcp.session: keyword that accepts a comma-separated subset
of {setup, established, closing} and matches packets whose TCP session
state falls within the named phases.

This lets a rule writer cover the full TCP lifecycle in one rule instead
of separate flow:not_established + flow:established rules.

Changes:
- New detect-tcp-session.{c,h} with parser, match function, unit tests
- Register DETECT_TCP_SESSION in detect-engine-register.{c,h}
- Add to Makefile.am source list
- Extend engine-analyzer text output for tcp.session:
- Extend firewall.json keyword_info with tcp_session phase values
- Update flow-keywords.rst documentation
- Require TCP protocol and SIG_FLAG_REQUIRE_PACKET at setup

Ticket: 7704
@codecov

codecov Bot commented Jul 31, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.35106% with 25 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.99%. Comparing base (8455efd) to head (961db21).

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #15962      +/-   ##
==========================================
- Coverage   83.03%   82.99%   -0.04%     
==========================================
  Files        1003     1005       +2     
  Lines      276582   276958     +376     
==========================================
+ Hits       229647   229866     +219     
- Misses      46935    47092     +157     
Flag Coverage Δ
fuzzcorpus 61.57% <6.16%> (+<0.01%) ⬆️
livemode 18.43% <6.16%> (-0.04%) ⬇️
netns 22.84% <13.01%> (-0.08%) ⬇️
pcap 45.37% <6.16%> (-0.09%) ⬇️
suricata-verify 67.11% <63.01%> (+0.03%) ⬆️
unittests 58.50% <84.84%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@yashda
yashda marked this pull request as ready for review August 1, 2026 16:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant