server: expand {a,b}/{1..10} host patterns in config; fuzz + tests

Hosts accept brace groups expanded at load time: enumeration {1,2,3},
inclusive ranges {2..5,8..10} with '..' syntax, and labels {a3,a4};
several groups multiply in cartesian fashion. Leading zeros are
preserved, each expanded machine gets its host as unique ID/name.

Malformed patterns (unmatched/nested braces, non-integer or descending
ranges, extra dots) and patterns expanding past 10000 machines fail at
startup. Adds table tests plus a FuzzExpandHostPattern target; the
safety cap keeps fuzzing and real configs from blowing up memory.
This commit is contained in:
2026-08-01 11:27:59 +02:00
parent 22706aad66
commit 41a01244c4
5 changed files with 390 additions and 2 deletions
+20
View File
@@ -104,6 +104,26 @@
# ssh:
# interval: 1m
# user: root
#
# # host patterns are expanded at load time. Inside a {...} group:
# # {1,2,3} enumeration -> 1, 2, 3
# # {2..5,8..10} inclusive numeric range -> 2, 3, 4, 5, 8, 9, 10
# # {a3,a4} labels (any non-range item is kept literally)
# # several groups multiply in cartesian fashion:
# # server-{a3,a4}-{1..2}.example.org
# # -> server-a3-1.example.org, server-a3-2.example.org,
# # server-a4-1.example.org, server-a4-2.example.org
# # leading zeros are preserved: {01..03} -> 01, 02, 03
# # a name: applies to every expanded machine.
# #
# # Bad patterns fail at startup: unmatched/nested braces, ranges with
# # non-integer endpoints or extra dots (e.g. {1..5..10}), and descending
# # ranges. A single pattern may expand to at most 10000 machines.
# - name: Server room
# machines:
# - host: server-{a3,a4}-{1..10}.example.org
# ssh:
# interval: 1m
# ---------- machines without a group (shown under "Machines") ----------
# machines: