Skip to content

config: test deterministic glob include ordering (v3) - #3281

Open
ssam18 wants to merge 1 commit into
OISF:masterfrom
ssam18:config-includes-glob-order-v3
Open

config: test deterministic glob include ordering (v3)#3281
ssam18 wants to merge 1 commit into
OISF:masterfrom
ssam18:config-includes-glob-order-v3

Conversation

@ssam18

@ssam18 ssam18 commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Depends on OISF/suricata#16031 (the include: glob feature, Redmine #8427, superseding OISF/suricata#15937). This test exercises that feature, so CI here will stay red until it is merged into OISF/suricata: suricata-verify CI builds suricata from the official branches (master/main-7.0.x/main-8.0.x), none of which have the feature yet. The pair is validated in the suricata PR's CI (which builds the feature and runs this exact branch via SV_BRANCH) and locally.

Previous PR: #3250

Changes since #3250

  • Rebased onto current master. No changes to the test itself.

    This is what caused the CI failures on conf-yaml: support glob patterns in include directive (v3) suricata#15937: that PR's CI checked out this branch (via SV_BRANCH) while it was still based on a June 5 master, 119 commits behind. The 26 failing tests there (bug-8489-*, detect-email-*, mime-dec-*, ftp-reply-received-02, http2-keywords2) were all tests whose expectations were updated on master on July 21 to match newer suricata main behavior — none of them are the glob test added here, which passed.

  • New PR rather than a force-push per the contribution workflow: the branch of an open PR should not be updated.


Adds config-includes-glob-order, a test for the include: glob-pattern support added in OISF/suricata (Redmine #8427).

glob.yaml includes *-order.yaml, which matches three drop-in files (01-order.yaml, 50-order.yaml, 99-order.yaml). Each defines its own unique marker key (glob-order-seen-NN). Because glob(3) returns matches in sorted (lexicographic) order, the files are merged in ascending numeric-prefix order. The common 01..99 drop-in directory convention.

Using --dump-config, the test asserts:

  • all three matched files were included (one unique marker key per file), and
  • the marker keys appear in sorted-filename order, observable because the config tree preserves insertion order.

No key is defined twice, so the test does not depend on duplicate-key override behaviour. What it pins is the sort order, which is what the numbered drop-in convention relies on in practice.

The glob config is kept in glob.yaml and run via command: rather than a shipped suricata.yaml, because suricata-verify runs suricata -c suricata.yaml --dump-config during test setup, before the min-version check.

A requires: script: probe greps src/conf-yaml-loader.c for the glob expansion code so the test skips on builds without the feature, and a second probe greps src/autoconf.h for HAVE_GLOB_H so it skips on builds without glob(3) (e.g. Windows), where an include pattern is skipped with a warning and the ordering checks cannot hold. See #3250 for the full history.

Ticket: https://redmine.openinfosecfoundation.org/issues/8427

Add config-includes-glob-order, which checks that a glob pattern in an include directive expands to all matching files and includes them in sorted order. glob.yaml includes *-order.yaml, matching three drop-in files (01/50/99) that each define their own unique marker key. The test asserts that all three keys are present in --dump-config output and that they appear in sorted-filename order, observable because the config tree preserves insertion order. No key is defined twice, so the test does not rely on duplicate-key override behavior.

Include order matters because settings from later includes override earlier ones, which is what makes the numbered 01..99 drop-in convention predictable for users.

The glob config is kept in glob.yaml and run via command: rather than a shipped suricata.yaml, because suricata-verify runs "suricata -c suricata.yaml --dump-config" during test setup before the min-version check. A glob include in suricata.yaml would break that setup step on Suricata versions without glob support.

Until the Suricata side lands, a requires script greps src/conf-yaml-loader.c for the glob expansion code and skips the test on builds without it, the same way the eve-alert-metadata tests probe for METADATA_DEFAULTS. This keeps CI green against main and the release branches.

A second requires script greps src/autoconf.h for HAVE_GLOB_H. Glob expansion needs glob(3), which Windows builds do not have; there an include pattern is skipped with a warning and none of the matched files are loaded, so the ordering checks could not hold. Probing the build rather than the platform keeps the test running everywhere glob(3) is available, including macOS and the BSDs.

Exercises the include glob support added in OISF/suricata for this ticket. Ticket: #8427
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

requires suricata pr Depends on a PR in Suricata

Development

Successfully merging this pull request may close these issues.

2 participants