Skip to content

Conversation

oferda4
Copy link

@oferda4 oferda4 commented Oct 19, 2025

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

Contribution style:

Our Contribution agreements:

Changes (if applicable):

Describe changes:
Allowing change the behaviour of --pcap-file-delete to only delete pcaps with no alerts via config.

Previous PR: #13934
Changes:

  • Refactor - avoid having pcap capture specific code in generic code using hooks.

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_BRANCH=OISF/suricata-verify#2664

Refactor pcap file deletion to use a single delete-when-done option
with three values instead of separate boolean options:
- false (default): No deletion
- true: Always delete files
- "non-alerts": Delete only files with no alerts

Key changes:
- Replace should_delete/delete_non_alerts_only bools with enum
- Move alert counter from global to per-file PcapFileFileVars
- Relocate alert counting from PacketAlertFinalize to pcap module
- Ensure thread safety for both single and continuous pcap modes
- Add comprehensive unit tests for configuration parsing

The --pcap-file-delete command line option overrides YAML config
and forces "always delete" mode for backward compatibility.

Documentation updated to reflect new three-value configuration.

Fixes OISF#7786
Copy link

NOTE: This PR may contain new authors.

Copy link

codecov bot commented Oct 19, 2025

Codecov Report

❌ Patch coverage is 97.67442% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.48%. Comparing base (96ae693) to head (45375e0).
⚠️ Report is 279 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #14078      +/-   ##
==========================================
+ Coverage   83.73%   84.48%   +0.75%     
==========================================
  Files        1011     1014       +3     
  Lines      275206   272338    -2868     
==========================================
- Hits       230445   230090     -355     
+ Misses      44761    42248    -2513     
Flag Coverage Δ
fuzzcorpus 63.41% <66.66%> (+0.27%) ⬆️
livemode 19.38% <16.66%> (+0.27%) ⬆️
pcap 44.88% <74.60%> (+0.08%) ⬆️
suricata-verify 65.30% <83.33%> (+0.24%) ⬆️
unittests 59.52% <89.53%> (+0.35%) ⬆️

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.

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