Skip to content

firewall: add default-policy to policy config v5.2 - #16091

Merged
victorjulien merged 3 commits into
OISF:mainfrom
lukashino:feat/8712-fw-default-policy-v5.2
Aug 25, 2026
Merged

firewall: add default-policy to policy config v5.2#16091
victorjulien merged 3 commits into
OISF:mainfrom
lukashino:feat/8712-fw-default-policy-v5.2

Conversation

@lukashino

@lukashino lukashino commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Follow-up of pre-approved #16069

Add a default-policy setting that applies to all hooks below it. For any hook the most specific setting present wins.
The flat layout had no way to express a default covering only the packet hooks or only the app hooks, so both move under their own node: packet-filter becomes packet.filter and <proto> becomes app.<proto>.
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/8712

Describe changes:
v5.2:

  • rebased
  • double-space removal

v5.1:

  • different fatalerror messages on error in the format fn
  • renamed FW_POLICY_PATH to FW_POLICY_YAML_PATH
  • touch up refactoring

v5:

  • polishing

v4:

  • refactor of policy querying to make it more readable
  • doc updates

v3:

  • commit message update

v1/v2:

  • new suricata.yaml policy config structure
  • policy hook validation and hints
  • multi-layer default policy for firewall policies

SV_BRANCH=OISF/suricata-verify#3307

To consider:

  1. As we changed the config structure for default policies, we can consider adding upgrade checks.
    But since the firewall mode is experimental in 8, I avoided any conversion checks from the previous versions to keep the code simpler.

  2. Visit https://redmine.openinfosecfoundation.org/issues/8712#note-17 for an updated configuration structure (could be worth it)

Lukas Sismis added 3 commits August 24, 2026 12:54
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: 8712
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.

DoParseAppSubStatePolicy() collapses into DoParseAppPolicy() as a sub state
hook only differs by an extra path segment.

Ticket: 8712
Validate the resolved scope against the class of hook it is being applied
to and fail at startup if it does not fit.

Ticket: 8712
Copilot AI lite review requested due to automatic review settings August 24, 2026 15:42
@lukashino
lukashino requested review from a team, jufajardini and victorjulien as code owners August 24, 2026 15:42

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

This PR extends Suricata’s experimental firewall-mode policy configuration by adding hierarchical default-policy inheritance and validating that action scopes are compatible with the hook class they ultimately apply to (e.g., preventing accept:tx from reaching packet hooks). It also updates documentation/examples to reflect the new configuration structure and semantics.

Changes:

  • Add multi-level default-policy inheritance for firewall hook policies (global → packet/app → protocol → sub-state → hook).
  • Enforce action-scope compatibility by hook class during policy resolution, turning previously silent misconfigurations into startup errors.
  • Refactor/commonize app-hook “generic” hook naming and update docs/examples accordingly.

Reviewed changes

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

Show a summary per file
File Description
suricata.yaml.in Updates the firewall policy configuration example/comments to introduce default-policy.
src/detect-parse.h Exposes a helper to derive generic app hook names for reuse across modules.
src/detect-parse.c Implements policy inheritance chain resolution + scope validation; refactors packet/app policy loading.
src/detect-engine-analyzer.c Reuses the shared generic-hook naming helper for analyzer output.
doc/userguide/firewall/firewall-design.rst Documents the new hierarchical policy structure, precedence rules, and scope validation behavior.

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

Comment thread suricata.yaml.in
Comment on lines 2400 to 2404
#policies:
# default-policy: ["drop:flow"]
# packet:
# filter: ["drop:packet"]
# app:

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.

Well this was supposed to just show possibilities. But it is true that we try to comment out the values that are actually default.
Perhaps this could be removed/leave just actual defaults. Related to it but irrelevant in this context, with that we could remove the per-interface-cpu-affinity node.

Comment thread src/detect-parse.c
@suricata-qa

Copy link
Copy Markdown

Information: QA ran without warnings.

Pipeline = 33262

@codecov

codecov Bot commented Aug 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 89.78102% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.04%. Comparing base (acd9d3a) to head (092ae27).

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #16091      +/-   ##
==========================================
- Coverage   83.05%   83.04%   -0.01%     
==========================================
  Files        1004     1004              
  Lines      277359   277366       +7     
==========================================
- Hits       230370   230352      -18     
- Misses      46989    47014      +25     
Flag Coverage Δ
fuzzcorpus 61.50% <0.00%> (-0.03%) ⬇️
livemode 18.41% <0.00%> (-0.18%) ⬇️
netns 22.88% <58.39%> (-0.03%) ⬇️
pcap 45.40% <0.00%> (-0.02%) ⬇️
suricata-verify 67.14% <89.78%> (-0.02%) ⬇️
unittests 58.53% <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.

@victorjulien victorjulien added this to the 9.0 milestone Aug 24, 2026
@victorjulien
victorjulien merged commit 092ae27 into OISF:main Aug 25, 2026
96 of 111 checks passed
@victorjulien

Copy link
Copy Markdown
Member

Merged in #16099, thanks!

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.

4 participants