Skip to content

conf-yaml: support glob patterns in include directive (v4) - #16031

Open
ssam18 wants to merge 1 commit into
OISF:mainfrom
ssam18:feat-8427-include-glob-v4
Open

conf-yaml: support glob patterns in include directive (v4)#16031
ssam18 wants to merge 1 commit into
OISF:mainfrom
ssam18:feat-8427-include-glob-v4

Conversation

@ssam18

@ssam18 ssam18 commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Continuation of #15937 (v4). See "Changes since #15937" below; no code changes since v3.

Contribution style:

Our Contribution agreements:

Changes (if applicable):

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

Previous PR: #15937

Describe changes:

SCConfYamlHandleInclude now expands shell-style glob patterns (*, ?, [) via glob(3) when the include path contains them. Each match is loaded in lexicographic (sorted) order; literal paths bypass glob() and take the existing per-file path. A pattern matching zero files is logged as a warning, not an error, so drop-in conf.d/-style directories may be empty. The precedent for the glob(3) shape and HAVE_GLOB_H gating is rule-files: in src/detect-engine-loader.c.

Changes since #15937

No code changes. The 26 suricata-verify failures on #15937's CI were not caused by this change: that CI run checked out the companion suricata-verify branch (OISF/suricata-verify#3250, via the SV_BRANCH line below), which was based on a June 5 suricata-verify master, 119 commits behind. The failing tests (bug-8489-*, detect-email-*, mime-dec-*, ftp-reply-received-02, http2-keywords2) were all tests whose expectations were updated on suricata-verify master on July 21 to match newer suricata main behavior, so the stale checkout ran old expectations against current code. The glob tests themselves passed, and main was green on the same days.

Changes since #15574 (carried over from v3)

Addresses @jasonish's review: "Document and accept that globbing doesn't work on Windows for now. Ideally with a warning message if the patterns are found."

  • Windows has no glob.h, so HAVE_GLOB_H is undefined and an include pattern fell through to be opened as a literal filename, failing with a confusing errno:

    Error: conf-yaml-loader: Failed to open configuration include file .../*-order.yaml: Invalid argument
    

    A pattern is now detected regardless of HAVE_GLOB_H and, on platforms without glob(3), logged and skipped instead:

    Warning: conf-yaml-loader: Glob patterns in include are not supported on this platform, skipping include .../*.yaml
    

    Literal includes are unaffected, including the existing hard error for a missing literal file.

  • Documented the platform limitation in doc/userguide/configuration/includes.rst and in the function's doxygen comment.

  • Rebased onto current main.

Skip vs. error. An unsupported pattern is a warning that continues, reading "accept that globbing doesn't work on Windows" as a documented platform limitation rather than a startup failure. The tradeoff is that a Windows user gets a partially-loaded config with only a warning. Happy to make it a hard error with an explicit message instead if you prefer that.

The suricata-verify test skips on builds without glob(3) by probing src/autoconf.h for HAVE_GLOB_H, so it no longer depends on the Windows runner incidentally failing the probe redirect.

Verification

Built with HAVE_GLOB_H undefined to exercise the Windows path directly:

case before after
pattern include, no glob(3) Error: Failed to open ... Invalid argument, exit 1 Warning: ... not supported on this platform, exit 0

On a normal build: all matched files load in lexicographic order, a no-match pattern still warns without failing, literal includes still work, a missing literal file still errors, and all 9 ConfYaml unit tests pass. suricata-verify: ===> config-includes-glob-order: OK, and SKIPPED on a build with HAVE_GLOB_H undefined.

The Windows CI failures on #15574 dated 2026-06-07 also predate the suricata-verify test rewrite of 2026-06-12, which removed the suricata.yaml that broke suricata-verify's setup step; the Ubuntu 24.04 (afpacket IPS tests in namespaces) failure there was a transient Codecov CLI GPG error, unrelated to the change.

Provide values to any of the below to override the defaults.

SV_BRANCH=OISF/suricata-verify#3281

SCConfYamlHandleInclude only accepted explicit filenames. The
rule-files directive has supported shell-style glob expansion via
glob(3) for years, and asymmetry with include has been blocking
clean drop-in conf.d/ style configuration directories.

Refactor SCConfYamlHandleInclude into a thin wrapper that resolves
the path against conf_dirname and, if the input contains glob
metacharacters (*, ?, [), expands it with glob(3) and includes
each match in lexicographic order. A pattern that matches no
files is logged as a warning and not treated as an error, so a
drop-in directory can be empty without breaking startup. Literal
paths skip glob() and call the existing per-file inclusion logic
directly, preserving current behaviour.

Glob expansion needs glob(3), which is not available everywhere.
Windows builds have no glob.h, so an include pattern used to fall
through and be opened as a literal filename, failing with a
confusing errno. On such platforms the pattern is now logged as a
warning and skipped instead. Literal includes are unaffected.

The behaviour is verified by the config-includes-glob-order
suricata-verify test, which checks that every file matching a
pattern is loaded and that matches are included in deterministic
lexicographic order.

Document the new behaviour, including the platform limitation, in
doc/userguide/configuration/includes.rst.

Feature: OISF#8427.
@codecov

codecov Bot commented Aug 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 82.75862% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.02%. Comparing base (bc4c064) to head (84a9087).
⚠️ Report is 13 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #16031      +/-   ##
==========================================
- Coverage   83.04%   83.02%   -0.02%     
==========================================
  Files        1002     1002              
  Lines      276722   276746      +24     
==========================================
- Hits       229794   229762      -32     
- Misses      46928    46984      +56     
Flag Coverage Δ
fuzzcorpus 61.61% <58.62%> (-0.11%) ⬇️
livemode 18.47% <31.03%> (-0.01%) ⬇️
netns 22.88% <0.00%> (-0.04%) ⬇️
pcap 45.38% <0.00%> (-0.08%) ⬇️
suricata-verify 67.13% <72.41%> (+<0.01%) ⬆️
unittests 58.47% <31.03%> (-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.

@jasonish
jasonish self-requested a review August 18, 2026 16:58
@jasonish jasonish self-assigned this Aug 18, 2026
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