conf-yaml: support glob patterns in include directive (v2) - #15574
Conversation
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. 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 in doc/userguide/configuration/ includes.rst. Feature: OISF#8427.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #15574 +/- ##
==========================================
- Coverage 82.88% 82.86% -0.03%
==========================================
Files 999 998 -1
Lines 272613 271884 -729
==========================================
- Hits 225968 225298 -670
+ Misses 46645 46586 -59
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
|
|
||
| Filenames in ``include`` may contain shell-style glob metacharacters | ||
| (``*``, ``?``, ``[...]``). Patterns are expanded at startup via | ||
| ``glob(3)`` and each matching file is loaded in lexicographic order. A |
There was a problem hiding this comment.
What does the 3 mean in glob(3) ?
|
This looks good to me but I left some remarks on the SV PR |
Jason and I do not agree on the desired behavior, so I leave the decision to him |
jasonish
left a comment
There was a problem hiding this comment.
The Windows failures are real:
checking for glob.h... no
There are a few options here.
- Ideally figure out if we're just missing a package in msys2?
- Document and accept that globbing doesn't work on Windows for now. Ideally with a warning message if the patterns are found.
Before 9 I plan to finish my Rust based loader and parser which would fix the Windows issue (I think), so we could just wait for that and accept no support on Windows for now.
|
Superseded by #15937 (v3), which addresses @jasonish's review: an include pattern is now detected regardless of A new PR rather than a push here, per the workflow: a branch should not be updated after its pull request is opened. The paired suricata-verify PR is now OISF/suricata-verify#3250 (v2 of OISF/suricata-verify#3151). For the record on the CI failures here: the three Windows/Ubuntu failures date from 2026-06-07 and are stale. The suricata-verify test was rewritten on 2026-06-12 to stop shipping a Closing in favour of #15937. Thanks @catenacyber and @jasonish for the reviews. |

Continuation of #15573 (v2). See "Changes since #15573" below.
Contribution style:
https://docs.suricata.io/en/latest/devguide/contributing/contribution-process.html
Our Contribution agreements:
https://suricata.io/about/contribution-agreement/
Changes (if applicable):
https://redmine.openinfosecfoundation.org/projects/suricata/issues
Link to ticket: https://redmine.openinfosecfoundation.org/issues/8427
Describe changes:
SCConfYamlHandleIncludenow expands shell-style glob patterns (*,?,[) viaglob(3)when the include path contains them. Each match is loaded in lexicographic (sorted) order; literal paths bypassglob()and take the existing per-file path. A pattern matching zero files is logged as a warning, not an error, so drop-inconf.d/-style directories may be empty. The precedent for theglob(3)shape andHAVE_GLOB_Hgating isrule-files:insrc/detect-engine-loader.c.Changes since #15573
HAVE_GLOB_Hunit tests (ConfYamlFileIncludeGlobTest,ConfYamlFileIncludeGlobNoMatchTest) and their registration are removed.config-includes-glob-order) specifically asserts that glob matches are included in deterministic lexicographic order (the01..99drop-in convention jasonish asked about): three drop-ins set the same key and the highest-prefix file wins under--dump-config.fopen(..., "w")calls inside the removed tests.Provide values to any of the below to override the defaults.
SV_BRANCH=OISF/suricata-verify#3151