Skip to content

Conversation

catenacyber
Copy link
Contributor

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

Describe changes:

  • detect/dataset: delay set operation after signature full match

SV_BRANCH=OISF/suricata-verify#2093

#13324 with just rebase to get green CI after vlan leak fix

The design is :

  • detect: postmatch can run AppLayerTxMatch callbacks (in its own commit)
  • usage of delay_postmatch: buffers using dataset/set are put at the tail of inspections whatever their progress
  • usage of DETECT_ENGINE_INSPECT_SIG_MATCH_MORE_BUF: dataset may return this new case to tell that ok we match on a multi-buffer, but we still want to try all occurrences of a multi-buffer (instead of returning a simple early match)

Will be useful for dataset, when it needs to find a transaction
buffer again.
Buffers can be put at the tail of inspections whatever their progress.

This will allow dataset/set to be inspected in the context of
the final packet matching or not, and thus use the ephemeral
data from DetectThreadCtxGetKeywordThreadCtx
DETECT_ENGINE_INSPECT_SIG_MATCH_MORE_BUF is the new return status
to allow dataset/set to pick all matching and only the matching
buffers in case of a multi-buffer
The set operation of dataset keyword was done even if signature
did not fully match, which is not the expected behavior.
We want dataset to behave like flowbits for instance.

This patch changes the behavior of the dataset keyword to do a
match and a post match for the set operation.
The postmatch retrieves the data, using the list identifier
associated to the buffer for this signature.

This avoids to store the buffer(s), when we do not have a
dedicated storage (per signature and per tx) that can own
and clean arbitrary buffers over multiple packets, in
the case the transaction spans over multiple packets
with different tx progresses for instance.

Thanks to delay_postmatch, the callback DetectDatasetTxMatch
should be called on the last packet taking the final match
decision. At this point, the inspection buffers are cached
and easy to get.
The most complex case is for multi-buffers, where we need
to know which buffers/local_ids matched. We use the ephemeral
storage (lives with one packet detection) provided by
DetectThreadCtxGetKeywordThreadCtx

For multi-buffers, we also return DETECT_ENGINE_INSPECT_SIG_MATCH_MORE_BUF
to indicate that we want to know all the instances which match.

Ticket: OISF#5576
Copy link

codecov bot commented Jun 1, 2025

Codecov Report

Attention: Patch coverage is 88.37209% with 20 lines in your changes missing coverage. Please review.

Project coverage is 83.41%. Comparing base (278a9c3) to head (f9b6639).
Report is 109 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #13346      +/-   ##
==========================================
- Coverage   83.42%   83.41%   -0.01%     
==========================================
  Files        1004     1004              
  Lines      273246   273378     +132     
==========================================
+ Hits       227952   228048      +96     
- Misses      45294    45330      +36     
Flag Coverage Δ
fuzzcorpus 62.04% <77.90%> (+0.01%) ⬆️
livemode 19.03% <38.37%> (+0.05%) ⬆️
pcap 44.91% <18.60%> (-0.03%) ⬇️
suricata-verify 65.05% <88.30%> (-0.01%) ⬇️
unittests 59.18% <17.54%> (-0.03%) ⬇️

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.

@suricata-qa
Copy link

Information: QA ran without warnings.

Pipeline 26316

@catenacyber
Copy link
Contributor Author

Rebased in #13415

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.

2 participants