Skip to content

config: test deterministic glob include ordering#3151

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

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

Conversation

@ssam18

@ssam18 ssam18 commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

Important

Depends on OISF/suricata#15574 (the include: glob feature, Redmine #8427). This test exercises that feature, so the 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, so suricata --dump-config fails on the glob include:. The pair is validated in #15574's CI (which builds the feature and runs this exact branch via SV_BRANCH) and locally.

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

suricata.yaml includes *-order.yaml, which matches three drop-in files (01-order.yaml, 50-order.yaml, 99-order.yaml) that each set the same key glob-order-test to a different value. Because glob(3) returns matches in sorted (lexicographic) order, the files are processed in ascending numeric-prefix order and the highest-numbered file is applied last — matching 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 final value of glob-order-test is file-99 (last in sorted order), not the baseline or an earlier file.

This addresses review feedback on the suricata PR (victorjulien/jasonish) requesting the include tests live in suricata-verify, with an explicit check that include ordering is deterministic.

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

Verified locally against a 9.0.0-dev build with the glob feature: ===> config-includes-glob-order: OK.

@ssam18
ssam18 force-pushed the config-includes-glob-order branch 2 times, most recently from 3cd34e5 to 3dbb6dd Compare June 7, 2026 04:02
@ssam18

ssam18 commented Jun 7, 2026

Copy link
Copy Markdown
Contributor Author

The 3 failing builds here are expected for now. This test exercises glob expansion in the config include directive, which is added by Suricata PR OISF/suricata#15574 and is not in suricata master yet. When suricata-verify builds suricata from master, the include is read as a literal filename, the file is not found, and suricata exits 1.

That suricata PR sets SV_BRANCH to this branch, so its own CI builds the glob feature and runs this test against it, where it passes. Running the same command locally against the feature build also exits 0 with the expected lexicographic ordering. This PR is meant to land together with or right after #15574, and once the feature is in master these builds will pass with no further changes.

@catenacyber catenacyber added the requires suricata pr Depends on a PR in Suricata label Jun 7, 2026
Comment thread tests/config-includes-glob-order/test.yaml Outdated
@ssam18
ssam18 force-pushed the config-includes-glob-order branch 2 times, most recently from d531ad0 to b8e7d55 Compare June 18, 2026 21:56
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.

Exercises the include glob support added in OISF/suricata for this ticket. Ticket: #8427
@ssam18
ssam18 force-pushed the config-includes-glob-order branch from b8e7d55 to c8f1b45 Compare July 10, 2026 20:31
@ssam18

ssam18 commented Jul 10, 2026

Copy link
Copy Markdown
Contributor Author

@jasonish that's exactly the scenario this test is meant to protect. I kept the marker keys unique per @catenacyber's earlier feedback, so the test pins just the sort order without relying on override behavior, but sorted expansion is what makes your sensor-name example predictable when the includes come from a glob.

On the red CI: the main jobs were failing because the glob support itself (OISF/suricata#15574) isn't merged yet, not because of the test logic. I've updated the test with a requires script that greps conf-yaml-loader.c for the glob expansion code and skips on builds without it, same approach the eve-alert-metadata tests use for METADATA_DEFAULTS. Verified locally: skips against current main (no match on 7.0.x/8.0.x either), passes against a build of the 15574 branch.

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.

3 participants