Skip to content

Backport 8.0.x/feat/8770 fw default policy v1 - #16110

Closed
lukashino wants to merge 3 commits into
OISF:main-8.0.xfrom
lukashino:backport-8.0.x/feat/8770-fw-default-policy-v1
Closed

Backport 8.0.x/feat/8770 fw default policy v1#16110
lukashino wants to merge 3 commits into
OISF:main-8.0.xfrom
lukashino:backport-8.0.x/feat/8770-fw-default-policy-v1

Conversation

@lukashino

Copy link
Copy Markdown
Contributor

Add a default-policy setting that applies to all hooks below it. For any hook the most specific setting present wins.
Action scopes are now validated against the hook they reach. A global accept:tx arriving at a packet hook is a startup error instead of being applied silently.

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

Backport of #16091

Describe changes:
v1:

  • clean backports except substates (not available in 8)

SV_BRANCH=OISF/suricata-verify#3317

Lukas Sismis added 3 commits August 25, 2026 20:31
Mapping an app-layer progress state to its generic request-/response-
hook alias was hardcoded in multiple places.

This commit adds a wrapper to unify it to a single function.
It returns the config-form (hyphenated) name, or NULL for an
intermediate state.

Ticket: 8770
(cherry picked from commit 1aa0259)
Every hook has a built-in default policy, but expressing anything other
than the built-in meant naming each hook explicitly.
This commit adds a `default-policy` setting that covers all hooks below it.
For any hook the most specific setting present wins.

Ticket: 8770
(cherry picked from commit 0aaa80d)
Validate the resolved scope against the class of hook it is being applied
to and fail at startup if it does not fit.

Ticket: 8770
(cherry picked from commit 092ae27)

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds hierarchical firewall default policies with hook-specific precedence and action-scope validation.

Changes:

  • Resolves packet and application policies through inherited defaults.
  • Validates action scopes against packet/application hooks.
  • Documents configuration precedence and supported scopes.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
src/detect-parse.h Exposes generic application-hook naming.
src/detect-parse.c Implements inheritance and scope validation.
src/detect-engine-analyzer.c Reuses generic hook naming.
doc/userguide/firewall/firewall-design.rst Documents defaults and precedence.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/detect-parse.c
Comment thread src/detect-parse.c
Comment on lines +4200 to +4201
struct DetectFirewallPolicy *pol = &fw_policies->pkt[id]; // built-in default
int r = ResolveFirewallPolicy(pol, DETECT_FIREWALL_POLICY_CLASS_PACKET, &chain);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This seems plausible, but will require a fix to main first. Will create a separate RM ticket.

@codecov

codecov Bot commented Aug 25, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 89.55224% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.68%. Comparing base (9b63a58) to head (b8bd2e0).
⚠️ Report is 9 commits behind head on main-8.0.x.

Additional details and impacted files
@@              Coverage Diff               @@
##           main-8.0.x   #16110      +/-   ##
==============================================
- Coverage       81.69%   81.68%   -0.02%     
==============================================
  Files            1016     1016              
  Lines          277166   277209      +43     
==============================================
+ Hits           226430   226437       +7     
- Misses          50736    50772      +36     
Flag Coverage Δ
fuzzcorpus 63.87% <0.00%> (-0.03%) ⬇️
livemode 18.61% <0.00%> (-0.07%) ⬇️
netns 20.14% <55.22%> (-0.01%) ⬇️
pcap 44.43% <0.00%> (-0.06%) ⬇️
suricata-verify 65.19% <89.55%> (-0.02%) ⬇️
unittests 58.58% <0.00%> (-0.01%) ⬇️

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 = 33347

@victorjulien victorjulien added this to the 8.0 milestone Aug 26, 2026
@victorjulien victorjulien added the needs rebase Needs rebase to main label Aug 26, 2026
@victorjulien
victorjulien self-requested a review August 26, 2026 06:53

@victorjulien victorjulien left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Needs a rebase to resolve a small conflict.

@lukashino

Copy link
Copy Markdown
Contributor Author

Continues in #16116

@lukashino lukashino closed this Aug 26, 2026
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.

4 participants