Skip to content

detect: allow bypass keyword for fw rules in firewall mode (only) - v5 - #16077

Closed
jufajardini wants to merge 15 commits into
OISF:mainfrom
jufajardini:fw-8459-allow-bypass/v5
Closed

detect: allow bypass keyword for fw rules in firewall mode (only) - v5#16077
jufajardini wants to merge 15 commits into
OISF:mainfrom
jufajardini:fw-8459-allow-bypass/v5

Conversation

@jufajardini

Copy link
Copy Markdown
Contributor

Previous PR: #16063

Describe changes:

  • rebased
  • improve docs based on previous PR's review
    Probably need tickets:
  • alerts suppressed by threshold fw rules now show in `detect.alerts_suppressed
  • fw alerts that should be suppressed for fw rules but that needed actions applied are not added to alert queue

Redmine ticket: https://redmine.openinfosecfoundation.org/issues/8459

SV_BRANCH=OISF/suricata-verify#3299

If the point is to check the docs for added changes, it makes sense to
that used binary is the one that comes with the doc changes. Thus, try
using the local binary first, before falling back to usr/bin installed
Suricata.
Previously, a rule that had firewall-only syntax or keywords would fail
the script check.

Since we can't guarantee that a firewall rule will look different than a
detection one, run rule examples against both scenarios before failing
them.
In case a keyword should work in firewall mode, with firewall rules
only. The engine errors out if threat detection rules use the given keyword.

Part of
Ticket OISF#8459
The bypass keyword should work in firewall mode, with firewall rules,
only. The engine errors out if threat detection rules use said keyword.

Ticket OISF#8459
If we add more firewall-related rule options, we can keep this opaque to
SigParseOptions.

Part of
Ticket OISF#8459
This allows banning variations of `action`:`scope` for specific
keywords.
Mostly having firewall rules in mind.

Done by introducing several SIGMATCH flags, to cover:
actions:
- config
- drop
- reject
action scopes:
- packet
- tx
- hook

`accept` and `flow` were left out as they would not be used for the work
at hand.

Part of
Ticket OISF#8459
A firewall rule only accepts the `bypass` keyword with the combination
of `accept:flow`. Thus, ban: `drop`, `reject`, `config`, `hook`, `tx`
and `packet` from firewall usage for this keyword.

Part of
Ticket OISF#8459
Especially related to firewall mode.

As part of
Ticket OISF#8459
If a firewall rule sets a flow to be bypassed, the triggering packet
could still be inspected by a threat detection rule with a drop.

Avoid that the `accept` from the firewall rule would still allow a TD
`drop` to be applied to the first packet.

This also implies that the stats for accept in such cases will now
differ between firewall and IPS, as the firewall accepted+bypassed
packet is never seen by ips (so can't be accepted).

Related to
Ticket OISF#8459
A packet bypassed by the firewall can't lead to ips stats counters
increments.
For a accept+bypass from the firewall, this implies that the stats for
accept in such cases will now differ between firewall and IPS, as the
firewall accepted+bypassed packet is never seen by ips (so can't be
counted as accepted).

Part of
Ticket OISF#8459
As a firewall rule skips the TD branch during PacketAlertQueue
finalizing, we must account for supressed alerts elsewhere, for firewall
rules.
PacketAlertHandle returns 2 if the alert is to be suppressed by
threshold, but actions should be applied. But the FirewallRule check was
adding rules to the alert queue if results were > 0.
@codecov

codecov Bot commented Aug 22, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 65.42056% with 37 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.02%. Comparing base (398687d) to head (6b649c5).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #16077      +/-   ##
==========================================
- Coverage   83.04%   83.02%   -0.02%     
==========================================
  Files        1004     1004              
  Lines      277359   277460     +101     
==========================================
+ Hits       230322   230368      +46     
- Misses      47037    47092      +55     
Flag Coverage Δ
fuzzcorpus 61.49% <24.29%> (-0.03%) ⬇️
livemode 18.43% <19.62%> (+0.01%) ⬆️
netns 22.87% <37.38%> (-0.04%) ⬇️
pcap 45.34% <21.49%> (-0.08%) ⬇️
suricata-verify 67.11% <65.42%> (-0.05%) ⬇️
unittests 58.51% <19.62%> (-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.

@suricata-qa

Copy link
Copy Markdown

Information: QA ran without warnings.

Pipeline = 33232

@jufajardini jufajardini added the needs rebase Needs rebase to main label Aug 24, 2026
@jufajardini

Copy link
Copy Markdown
Contributor Author

Must fix CI docs failure, and rebase (so I don't need the check-docs commits)

@jufajardini

Copy link
Copy Markdown
Contributor Author

Replaced by: #16120

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs rebase Needs rebase to main

Development

Successfully merging this pull request may close these issues.

2 participants